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
// helper functions | |
const compose = (...fns) => x => fns.reduceRight((res, fn) => fn(res), x); | |
const tap = f => x => { f(x); return x; }; | |
const trace = label => tap(console.log.bind(console, label + ':')); | |
// container helpers | |
const isFunction = fn => fn && Object.prototype.toString.call(fn) === '[object Function]'; | |
const isAsync = fn => fn && Object.prototype.toString.call(fn) === '[object AsyncFunction]'; |
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
// #1 - for | |
let images = [ 'test.jpg', 'dummy.gif' ]; | |
for (let i = 0; i < allImgs.length; i++) {} // long | |
for (let i of allImgs) { } // short | |
// #2 - decimal base | |
1000000 === 1e6 | |
// #3 - default parameters | |
volume = (l, w = 3, h = 4 ) => (l * w * h); |
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
// 123456789 -> 123,456,789 | |
n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); |
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 function tryCatch({ | |
tryer, | |
catcher | |
}) { | |
return (props) => { | |
try { | |
return tryer(props); | |
} catch (e) { | |
return catcher(props, e.message); | |
} |
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 const conditionally = <Props, Result>(options: { | |
if: (props: Props) => any; | |
then: (props: Props) => Result | Result; | |
else: (props: Props) => Result | Result; | |
}) => (props: Props) => { | |
return options.if(props) ? options.then(props) : options.else(props); | |
}; |
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
items: [ | |
{key: 1, title: "ONE"}, | |
{key: 2, title: "TWO"}, | |
{key: 3, title: "THREE"} | |
], |
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
import Ember from 'ember'; | |
import {inject as controller} from '@ember/controller'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
myvar: '', | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
queryParams: ['search'], | |
search: '', | |
}); |
NewerOlder