This file contains 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
//https://www.keithcirkel.co.uk/metaprogramming-in-es6-symbols/ | |
//Symbol | |
//Giving developers ability to add hooks to their objects, through your API | |
// Retreive the magic inspect Symbol from the API's Symbol constants | |
var inspect = console.Symbols.INSPECT | |
var myVeryOwnObject = {} | |
console.log(myVeryOwnObject) // logs out `{}` |
This file contains 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
//module version | |
var Module = (function (window) { | |
function privateFunction() { | |
console.log('pass'); | |
}; | |
var privateClass = function () {}; | |
var publicClass = function () {}; |
This file contains 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
var isEmpty = (a, b, c) => { | |
return ![a, b, c].join(""); | |
} | |
var isEmpty = (...rest) => { | |
return !rest.join(""); | |
} | |
isEmpty(void 0, [], null) // => true | |
isEmpty(void 0, [], null, 0) // => false |
This file contains 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
0 < null; // false | |
0 > null; // false | |
0 == null; // false | |
0 <= null; // true | |
0 >= null // true | |
-1 == false; // => false | |
-1 == true; // => false |
This file contains 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
const Storage = Sup => class extends Sup { | |
save(database) { } | |
} | |
const Validation = Sup => class extends Sup { | |
validate(schema) { } | |
} | |
class Person { } | |
class Employee extends Storage(Validation(Person)) { } |
This file contains 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
function makeAjaxCall(someValue) { | |
return (dispatch, getState) => { | |
dispatch({type : "REQUEST_STARTED"}); | |
myAjaxLib.post("/someEndpoint", {data : someValue}) | |
.then(response => dispatch({type : "REQUEST_SUCCEEDED", payload : response}) | |
.catch(error => dispatch({type : "REQUEST_FAILED", error : error}); | |
}; | |
} |
This file contains 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
const {create, env} = require('sanctuary') | |
const checkTypes = false | |
//or enable it only in developement | |
//const checkTypes = process.env.NODE_ENV !== 'production' | |
const S = create({checkTypes: checkTypes, env: env}) | |
module.exports = S |
This file contains 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
const R = require('ramda') | |
const flatRestArgs = p=>(...e)=>(p)(R.flatten(e)) | |
const reducer = R.reduceRight(R.flip(R.call)) | |
const listAdapter = R.converge(reducer,[R.last,R.init]) | |
const fpipe = flatRestArgs( listAdapter ) | |
module.exports = fpipe | |
//===EXAMPLE=== |
This file contains 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
const winston = require('winston') | |
const R = require('ramda') | |
const chalk = require('chalk') //console colorizer | |
const P = R.pipe //Short form for pipe: the most frequently used function | |
const yellowTag = chalk.bold.yellow | |
const redTag = chalk.bold.bgRed.black | |
//Simply write 'error' and its will be marked red, | |
//and any other wiil be yellow if its hasnt have color yet |
This file contains 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
const resolver = delay => resolve => setTimeout(() => resolve(delay), delay) | |
const pause = (delay=5000) => new Promise(resolver(delay)) | |
module.exports = pause |
OlderNewer