Every single JavaScript engine supports standard timers *
These accept one or more extra argument by specs
for(var i = 0; i < 2; i++) {
setTimeout(function (i) {
console.log(i);
}, 0, i); // <== see this?
}| (function (Object, Original) {'use strict'; | |
| // (C) Andrea Giammarchi - WTFPL | |
| OP = Original.prototype; | |
| if ('cancel' in OP) return; | |
| var | |
| OP, | |
| $then = OP.then, |
| (function (Object, Original) {'use strict'; | |
| // (C) Andrea Giammarchi - WTFPL | |
| if (Original._isPatch) return; | |
| var | |
| $then = Original.prototype.then, | |
| $catch = Original.prototype.catch, | |
| defineProperty = Object.defineProperty, |
| var WeakMap = WeakMap || (function () {'use strict'; | |
| // "memory-safer" alternative to Polymer WeakMap | |
| // probably less performant but it's OK | |
| // since deleting is really a rare case with WM anyway | |
| // (C) Andrea Giammarchi - MIT Style License | |
| function WeakMap() { | |
| defineProperty(this, id, {value: id + i++}); | |
| } | |
| var | |
| defineProperty = Object.defineProperty, |
| #!/usr/bin/env bash | |
| echo '' | |
| if [ "$1" = "" ]; then | |
| echo 'csp sha1 and sha256 generatoor' | |
| echo 'csp "code"' | |
| echo 'csp /file-name' | |
| else | |
| if [ -f "$1" ]; then | |
| CONTENT=$(cat $1) |
| /** server */ | |
| var | |
| port = 3000, | |
| server = require('http').createServer(function (req, res) { | |
| res.writeHead(200, {'Content-Type': 'text/html'}); | |
| res.end('<!DOCTYPE html>'.concat( | |
| '<html>', | |
| '<head>', | |
| '<script>(', client, ').call(this);</script>', | |
| '</head>', |
| // Andrea Giammarchi, WTFPL | |
| function slice() {'use strict'; | |
| for (var | |
| o = +this, // offset | |
| i = o, // start index | |
| l = arguments.length, // length | |
| n = l - o, // new length | |
| a = Array(n < 0 ? 0 : n); // new Array | |
| i < l; i++ | |
| ) a[i - o] = arguments[i]; |
Every single JavaScript engine supports standard timers *
These accept one or more extra argument by specs
for(var i = 0; i < 2; i++) {
setTimeout(function (i) {
console.log(i);
}, 0, i); // <== see this?
}| /* HTML.md | |
| a silly idea by Andrea Giammarchi */ | |
| .md h1:before { | |
| content: '# '; | |
| } | |
| .md h2:before { | |
| content: '## '; | |
| } | |
| .md h3:before { | |
| content: '### '; |
| function isArguments(obj) { | |
| return obj && | |
| typeof obj === 'object' && | |
| Object.prototype.hasOwnProperty.call(obj, 'length') && | |
| !Object.prototype.propertyIsEnumerable.call(obj, 'length') && | |
| !Array.isArray(obj); | |
| } | |
| // should be more reliable | |
| function isArguments(obj) { |
update
I've created a little repository that simply exposes the final utility as npm module.
It's called html-escaper
there is basically one rule only: do not ever replace one char after another if you are transforming a string into another.