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
let words = "aaa ggg aaa ggg aaa ffff aaa ggg aaa ggg aaa fff rrrr aaa"; | |
let y = _.compose( | |
_.get('word'), | |
_.head, | |
_.orderBy('count', 'desc'), | |
_.map(p=>({word:p[0], count:p[1]})), | |
_.toPairs, | |
_.reduce((acc, next) => { | |
acc[next] = (acc[next] && acc[next]+1) || 1; | |
return acc; |
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
let y = [ | |
{name:'g', phone:1111}, | |
{name:'a', phone:11112}, | |
{name:'b', phone:11113}, | |
{name:'l', phone:11115} | |
] | |
let phones = _.compose(_.map(_.get('phone')), _.sortBy('name'))(y); | |
console.log(phones); |
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
let y = "aaa fff fnfnfnf fnfnfnfnf"; | |
console.log(_.flow(_.split(' '), _.reduce((acc)=>{acc++; return acc;},0))(y)); |
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
let y = ['kii', 'loo']; | |
console.log(_.map(_.flow(_.split(''), _.take(2), _.join('')))(y)); |
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
let x = [ | |
{ | |
obj: { | |
name:'Julia' | |
} | |
}, | |
{ | |
obj: { | |
name:'Vadim' | |
} |
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
let x = [ | |
{ | |
obj: { | |
name:'Julia' | |
} | |
}, | |
{ | |
obj: { | |
name:'Vadim' | |
} |
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
console.log(_.compose(_.map(_.size), _.split(' '))('aaa tttt')); |
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 g = x => y => x > y? x : y; | |
let arr= [99, 5,4,3, 9999,6]; | |
let max = arr.reduce((max, next) => g(max(next)), g(arr.slice(1))); | |
console.log(max(0)); |
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
import {CoreServices as services} from '../service/core-services'; | |
/** | |
* This is a decorator with ngRedux and Angular 1. | |
*/ | |
const reduxConnect = mapStateToParams => target => { | |
const echanced$onInit = function () { | |
let $ngRedux = services.$injector.get('$ngRedux'); | |
let disconnect = $ngRedux.connect(target.prototype[mapStateToParams])(this); | |
this.$scope.$on('$destroy', disconnect); |
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
val = 'aaa.bb.ccc'; | |
let [x] = val.split('.').slice(-1); | |
expect(x).toBe('ccc'); |