-
Lots of type inference
-
Null/undefined checking
Object.defineProperties(Object, { | |
'extend': { | |
'configurable': true, | |
'enumerable': false, | |
'value': function extend(what, wit) { | |
var extObj, witKeys = Object.keys(wit); | |
extObj = Object.keys(what).length ? Object.clone(what) : {}; | |
witKeys.forEach(function (key) { |
var flatten = (a, r, cb) => { | |
if (typeof a.length === 'undefined') { | |
r.push(a); | |
return cb; | |
} else if (a.length === 0) { | |
return cb; | |
} else { | |
return flatten(a[0], r, () => flatten(a.slice(1), r, cb)); | |
} | |
}; |
const Range = (a, b) => Array.from({ length: b - a }, (_, i) => a + i) | |
const NumTest = (n, text) => k => !(k % n) ? text : '' | |
const Tests = data => Object.entries(data).map(([n, text]) => NumTest(n, text)) | |
const RangeTest = tests => n => tests.map(fn => fn(n)).join('') || n | |
const RangeMap = (a, b, tests) => Range(a, b).map(RangeTest(tests)) | |
const fizzBuzz = (a, b) => RangeMap(a, b, Tests({ | |
5: 'Fizz', | |
3: 'Buzz', | |
})) |
Originally conceived by Dave Herman, based on: http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Flist..rkt%29._build-list%29%29
There is no easy way to create an array, of user defined length, containing values that are not undefined
. Easily build range
functionality ontop.
I'm not suggesting drastic action. I don't want to break backwards compatibility. I simply want to make the class
feature more usable to a broader cross section of the community. I believe there is some low-hanging fruit that can be harvested to that end.
Imagine AutoMaker contained class Car
, but the author wants to take advantage of prototypes to enable factory polymorphism in order to dynamically swap out implementation.
Stampit does something similar to this in order to supply information needed to inherit from composable factory functions, known as stamps.
This isn't the only way to achieve this, but it is a convenient way which is compatible with .call()
, .apply()
, and .bind()
.
window.console.clog = function(log){ | |
var message = typeof log === 'object' ? '%cLooks like you\'re trying to log an ' : '%cLooks like you\'re trying to log a ', | |
style = 'background:url(http://i.imgur.com/SErVs5H.png);padding:5px 15px 142px 19px;line-height:280px;'; | |
console.log.call(console, message + typeof log + '.', style); | |
}; |
#!/bin/bash | |
# Description: | |
# Delete all `greenkeeper/*` branches of your remote. | |
# Instructions: | |
# Run the script with the `--help` flag. | |
ORIGIN=origin | |
DRY_RUN=0 | |
THIS=`basename "$0"` |
- Sync/async generator forms
- Not constant, can be reassigned
- Hoisting can result in runtime exceptions (https://twitter.com/OliverJAsh/status/1247240674388447234)
First and foremost, let's take a look at the following pieces of code. The first one is something you should be rather familiar with, and the second one is also a somewhat familiar idiom these days (at least in languages with higher-order functions):
// Example 1:
30 + 12
// Example 2:
xs.map(f)