This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let things = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
let other = things | |
.map(function(num) { return num + 1; }) // creates a new array that contains [2, 3, 4, 5, 6, 7, 8, 9, 10, 11] and returns it | |
.filter(function(num) { return num % 3 === 0; }) // reduces the array contents so that it contains [3, 6, 9] and returns it | |
.join(' -> '); // joins the values and returns a string '3 -> 6 -> 9' | |
// This could just as easily be written as follows | |
let a = things.map(function(num) { return num + 1; }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface Promisify { | |
<T>(func: (callback: (err: any, result: T) => void) => void): () => Promise<T>; | |
<T, A1>(func: (arg1: A1, callback: (err: any, result: T) => void) => void): (arg1: A1) => Promise<T>; | |
<T, A1, A2>(func: (arg1: A1, arg2: A2, callback: (err: any, result: T) => void) => void): (arg1: A1, arg2: A2) => Promise<T>; | |
<T, A1, A2, A3>(func: (arg1: A1, arg2: A2, arg3: A3, callback: (err: any, result: T) => void) => void): (arg1: A1, arg2: A2, arg3: A3) => Promise<T>; | |
<T, A1, A2, A3, A4>(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: (err: any, result: T) => void) => void): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Promise<T>; | |
<T, A1, A2, A3, A4, A5>(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: (err: any, result: T) => void) => void): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Promise<T>; | |
} | |
/** | |
* @example: const rReadFile = promisify<Buffer, string>(fs.readFile); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "test", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"repository": { | |
"type": "git", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"plugins": [ | |
"transform-es2015-destructuring", | |
"transform-es2015-function-name", | |
"transform-es2015-modules-commonjs", | |
"transform-es2015-parameters", | |
"transform-es2015-spread", | |
"transform-object-rest-spread", | |
"transform-async-to-generator", | |
"transform-function-bind" |
NewerOlder