Skip to content

Instantly share code, notes, and snippets.

@ainthek
ainthek / gist:5095320
Last active December 14, 2015 13:39
json-schema, generator (dojo, AMD)
define([
"dojo/date/stamp",
"dojo/_base/lang"
], function(dates, lang) {
// summary:
// very first draft of obj2json-schema generator
var DEFAULT_OPTIONS = {
numberInteger : true,
numberPositive : false, //sets minimum to 0 for positive numbers
numberJsMinMax : false, //TODO: implement ranges
@ainthek
ainthek / array.indexDiff
Created September 24, 2015 13:51
compare two arrays and produceintersection, a diff b b diff a (compare is based on lengths/indexed, not sparse arrays)
var oldA = ['o1', 'o2', 'o3', 'o4'],
newA = ['n0', 'n1', 'n2'];
//var oldA=['o1','o2'],newA=['n0','n1','n2'];
//var oldA=['o1','o2'],newA=['n0','n1'];
var changed = oldA.slice(0, Math.min(oldA.length, newA.length));
var added = newA.slice(oldA.length);
var deleted = oldA.slice(newA.length);
console.log(changed, added, deleted);