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 encoder = new TextEncoder() | |
const decoder = new TextDecoder() | |
const ALGORITHMS = { | |
HS: { name: 'HMAC' }, | |
ES: { name: 'ECDSA', namedCurve: 'P-256' }, | |
RS: { name: 'RSASSA-PKCS1-v1_5', modulusLength: 2048, publicExponent: new Uint8Array([0x01, 0x00, 0x01]) }, | |
PS: { name: 'RSA-PSS', saltLength: 128, modulusLength: 2048, publicExponent: new Uint8Array([0x01, 0x00, 0x01]) }, | |
} |
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
function schase(models, objects = {}) { | |
function resolve(data) { | |
for(const [ name, object ] of Object.entries(data)) { | |
const [ _, base, ref ] = /(.*?)(_id|Id|Ids|_ids)?$/.exec(name) | |
const [ plural ] = /es|s$/.exec(ref) || [] | |
const model = base.replace(/es|s$/, '') | |
if(!objects[model]) objects[model] = {} |
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
self.setImmediate = cb => Promise.resolve().then(cb) | |
var fsModule = new Blob([` | |
module.exports = { | |
readdirSync() { | |
return [] | |
}, | |
readFileSync(file) { | |
const xhr = new XMLHttpRequest() |
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
var html = heredoc ` | |
<section> | |
<h1> title</h1> | |
<p>content</p> | |
</section> | |
` |
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
var {ARRAY, NUMBER, STRING, BOOLEAN, OBJECT} = { | |
ARRAY: Symbol('array'), | |
OBJECT: Symbol('object'), | |
NUMBER: Symbol('number'), | |
STRING: Symbol('string'), | |
BOOLEAN: Symbol('boolean'), | |
} | |
function flatMap(list, callback) { | |
const result = [] |
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
var structure = (function () { | |
"use strict"; | |
function BaseStruct(values) { | |
for(var i= values.length-1; i>= 0; i--) { | |
this[i] = values[i] | |
} | |
} | |
BaseStruct.prototype.toJSON = function toJSON() { | |
var array = new Array(this.length) | |
for(var i = array.length-1; i >= 0; i--) { |
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
/** | |
Creates a new Objserver. | |
@class Observes an object and updates its value on changes that are applied. | |
@param [value] - Optional init value; - | |
*/ | |
function Objserver(value) { | |
this.$value = value; | |
this.$change = []; | |
} | |
function jsonPath(obj,string) { |
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
function addScript(src) { | |
var script = document.createElement("script"); | |
script.src = src; | |
document.body.appendChild(script); | |
return addScript; | |
} | |
addScript('//rawgithub.com/kriskowal/q/master/q.min.js'); | |
/** | |
* A Object wrapper with some iteration helpers. | |
* @constructor |
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
var fn = require('to-function'); | |
function toObject(keys,values) { | |
var rv = {}; | |
for (var i = 0; i < keys.length; ++i) | |
if (keys[i] !== undefined) rv[keys[i]] = values[i]; | |
return rv; | |
} | |
function h(f) { | |
var args = f.split("=>")[0].split(","); | |
var func = f.split("=>")[1].split('-').map(function(fs){ |
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
function stringDebug(sender, method, object) { | |
var tostring =Object.prototype.toString; | |
Object.prototype.toString = function(padding) { | |
padding = padding || 3; | |
var res = Array(padding-2).join(" ")+"{"; | |
var _self = this; | |
for(var attr in _self) { | |
res += '\n' + Array(padding).join(" ") + attr + " : " + ((this[attr] && (padding +2) < 12) ? this[attr].toString(padding +2) : "null"); | |
} | |
return res+"\n"+Array(padding-2).join(" ")+"}"; |
NewerOlder