Skip to content

Instantly share code, notes, and snippets.

View sharmaabhinav's full-sized avatar
😀
Working

ABHINAV SHARMA sharmaabhinav

😀
Working
  • Bangalore
View GitHub Profile
const compose = (...fns) => (arg) => fns.reduce((composed, f) => f(composed), arg)
const oneSecond = () => 1000
const getCurrentTime = () => new Date()
const clear = () => { console.clear() }
const log = (message) => { console.log(message) }
const serializeClockTime = date => ({
hours: date.getHours(),
minutes: date.getMinutes(),
seconds: date.getSeconds()
function showCountDown () {
var nextdate = new Date(2017, 9, 24, 10)
var curDate = new Date()
var seconds, minutes, hours
seconds = Math.floor((nextdate - curDate) / 1000)
minutes = Math.floor(seconds / 60 )
seconds = seconds % 60
hours = Math.floor(minutes/60)
minutes = minutes % 60;
Array.prototype.dup = function (n) {
var arr = []
for(var i=1;i<=n;i++) {
arr = arr.concat(this)
}
return arr
}
function bind (fn, context, params) {
return function callable () {
fn.apply(context, [...params, ...arguments])
}
}
/*
function foo (a,b,c) {
function groupBy (collection, func, callback) {
if (typeof func !== 'function') {
callback('please provide a function to group by')
return
}
if (typeof callback !== 'function') {
callback('please provide a function as a callback')
return
}
function head (arr) {
var [start, ...rest] = arr;
return start;
}
function tail (arr) {
var [start, ...rest] = arr;
return rest;
}
var _ = {pick}
function pick (object, identifierStr) {
var path = identifierStr.split('.')
if (path.length === 1 ) {
return object[path[0]]
}
var [first, ...rest] = path
return pick(object[first], rest.join('.'))
}
var Something = {
cool: function() {
this.greeting = "Hello World";
this.count = this.count ? this.count + 1 : 1;
}
};
Something.cool();
console.log(Something.greeting)
console.log(Something.count);
function isRelatedTo (o1, o2) {
function F() {}
F.prototype = o2
return o1 instanceof F
}
if (!Object.create) {
Object.create = function(o) {
function F(){}
F.prototype = o;
function apply (fn, context, params) {
return fn.call(context, ...params)
}
var obj = {a: 2}
function foo (b,c,d) {
console.log(this.a, b, c, d)
}