Skip to content

Instantly share code, notes, and snippets.

View thinnakrit's full-sized avatar
🏕️
I love camping :D

Thinnakrit thinnakrit

🏕️
I love camping :D
View GitHub Profile
const Cycle = require('cycle-react');
const React = require('react');
const ReactDOM = require('react-dom');
const Rx = require('rx');
const Counter = Cycle.component('Counter', (interactions, props) =>{
return props.get('counter').map(counter =>{
var now = new Date().getTime();
var distance = props.value.countDownDate - now;
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
_.chunk(['a', 'b', 'c', 'd'], 2);
// => [['a', 'b'], ['c', 'd']]
 
_.chunk(['a', 'b', 'c', 'd'], 3);
// => [['a', 'b', 'c'], ['d']]
_.compact([0, 1, false, 2, '', 3]);
// => [1, 2, 3]
var array = [1];
var other = _.concat(array, 2, [3], [[4]]);
console.log(other);
// => [1, 2, 3, [4]]
console.log(array);
// => [1]
_.difference([2, 1], [2, 3]);
// => [1]
_.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
// => [1.2]
// The `_.property` iteratee shorthand.
_.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
// => [{ 'x': 2 }]
_.drop([1, 2, 3]);
// => [2, 3]
_.drop([1, 2, 3], 2);
// => [3]
_.drop([1, 2, 3], 5);
// => []
_.drop([1, 2, 3], 0);
_.dropRight([1, 2, 3]);
// => [1, 2]
_.dropRight([1, 2, 3], 2);
// => [1]
_.dropRight([1, 2, 3], 5);
// => []
_.dropRight([1, 2, 3], 0);
// dropWhile
var users = [
{ 'user': 'barney', 'active': false },
{ 'user': 'fred', 'active': false },
{ 'user': 'pebbles', 'active': true }
];
_.dropWhile(users, function(o) { return !o.active; });
// => objects for ['pebbles']
// intersection
_.intersection([2, 1], [2, 3]);
// => [2]
// intersectionBy
_.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
// => [2.1]