Housekeeping, tag and build
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
### 3DigHexcode to 6DigHexcode
|
||||
### 3-digit hexcode to 6-digit hexcode
|
||||
|
||||
Use `Array.map()`, `split()` and `Array.join()` to join the mapped array for converting a three-digit RGB notated hexadecimal colorcode to the six-digit form.
|
||||
Use `Array.map()`, `split()` and `Array.join()` to join the mapped array for converting a three-digit RGB notated hexadecimal colorcode to the six-digit form.
|
||||
|
||||
```js
|
||||
const convertHex = shortHex =>
|
||||
shortHex[0] == '#' ? ('#' + shortHex.slice(1).split('').map(x => x+x).join('')) :
|
||||
const convertHex = shortHex =>
|
||||
shortHex[0] == '#' ? ('#' + shortHex.slice(1).split('').map(x => x+x).join('')) :
|
||||
('#' + shortHex.split('').map(x => x+x).join(''));
|
||||
// convertHex('#03f') -> '#0033ff'
|
||||
// convertHex('05a') -> '#0055aa'
|
||||
@ -5,6 +5,6 @@ You can omit `start` to use a default value of `0`.
|
||||
|
||||
```js
|
||||
const initializeArrayRange = (end, start = 0) =>
|
||||
Array.from({ length: end - start }).map((v, i) => i + start)
|
||||
Array.from({ length: end - start }).map((v, i) => i + start);
|
||||
// initializeArrayRange(5) -> [0,1,2,3,4]
|
||||
```
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
### Pipe
|
||||
### Pipe functions
|
||||
|
||||
Use `Array.reduce()` with the spread operator (`...`) to perform left-to-right function composition.
|
||||
The first (leftmost) function can accept one or more arguments; the remaining functions must be unary.
|
||||
@ -1,4 +1,4 @@
|
||||
### Read a file to an Array
|
||||
### Read file as array of lines
|
||||
|
||||
Use `readFileSync` function in `fs` node package to create a `Buffer` from a file.
|
||||
convert buffer to string using `toString(encoding)` function.
|
||||
@ -16,4 +16,4 @@ const readFileToArray = filename => fs.readFileSync(filename).toString('UTF8').s
|
||||
let arr = readFileToArray('test.txt')
|
||||
console.log(arr) // -> ['line1', 'line2', 'line3']
|
||||
*/
|
||||
```
|
||||
```
|
||||
@ -1,4 +1,4 @@
|
||||
### Take every nth element of an array
|
||||
### Take every nth element
|
||||
|
||||
Use `Array.filter()` to create a new array that contains every nth element of a given array.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user