Comparing version 0.0.8 to 0.1.0
108
n8iv._.js
(function(root) { | ||
function $A(a, i, j) { | ||
return got(a, LEN) ? slice.call(a, isNum(i) ? i > 0 ? i : 0 : 0, isNum(j) ? j > i ? j : i + 1 : a[LEN]) : [ a ]; | ||
return got(a, "length") ? slice.call(a, isNum(i) ? i > 0 ? i : 0 : 0, isNum(j) ? j > i ? j : i + 1 : a.length) : [ a ]; | ||
} | ||
function bless(ns, ctx) { | ||
switch (n8iv_type(ns)) { | ||
case ARR: | ||
case "array": | ||
break; | ||
case STR: | ||
case "string": | ||
ns = ns.split("."); | ||
@@ -19,3 +19,3 @@ break; | ||
} | ||
if (!ns[LEN]) return blessCTX(ctx); | ||
if (!ns.length) return blessCTX(ctx); | ||
!ns[0].startsWith("^") || (ctx ? ns.shift() : ns[0] = ns[0].substring(1)); | ||
@@ -31,3 +31,3 @@ ctx = blessCTX(ctx); | ||
function blessCTX(ctx) { | ||
if (ENV == CJS) return ctx ? ctx instanceof Module ? ctx[EXPS] : ctx : module[EXPS]; else return ctx || root; | ||
if (ENV == CJS) return ctx ? ctx instanceof Module ? ctx.exports : ctx : module.exports; else return ctx || root; | ||
} | ||
@@ -38,7 +38,7 @@ function bool(o) { | ||
return F; | ||
case BOOL: | ||
case "boolean": | ||
return o; | ||
case NUM: | ||
case "number": | ||
return o !== 0 && !isNaN(o); | ||
case STR: | ||
case "string": | ||
return !booleans.some(function(v) { | ||
@@ -62,7 +62,7 @@ return v === o; | ||
!(desc.get || desc.set) || delete desc.writable; | ||
if (overwrite === T || !exists) Object.defineProperty(item, name, desc); else if (debug === T && exists) trace().error(new Error("Trying to overwrite existing property: " + name + ", in: " + (isFn(item) ? item.n8ivName : item[CTOR].n8ivName) + "."), T); | ||
if (overwrite === T || !exists) Object.defineProperty(item, name, desc); else if (debug === T && exists) trace().error(new Error("Trying to overwrite existing property: " + name + ", in: " + (isFn(item) ? item.n8ivName : item.constructor.n8ivName) + "."), T); | ||
return n8iv; | ||
} | ||
function defs(item, o, m, overwrite, debug) { | ||
m || (m = cw); | ||
m || (m = "cw"); | ||
for (var k in o) !has(o, k) || def(item, k, describe(o[k], m), overwrite, debug); | ||
@@ -82,6 +82,6 @@ return n8iv; | ||
switch (n8iv_type(e)) { | ||
case ERR: | ||
case "error": | ||
msg = e.message; | ||
break; | ||
case STR: | ||
case "string": | ||
msg = String(e); | ||
@@ -91,3 +91,3 @@ e = new Error(e); | ||
} | ||
!(ERR in console) || console.error(msg); | ||
!("error" in console) || console.error(msg); | ||
if (chuck === T) throw e; | ||
@@ -97,3 +97,3 @@ return n8iv; | ||
function exists(o) { | ||
return o !== N && o !== U && (typeof o == NUM ? !isNaN(o) : T); | ||
return o !== N && o !== U && (typeof o == "number" ? !isNaN(o) : T); | ||
} | ||
@@ -116,3 +116,3 @@ function got(o, k) { | ||
function n8iv_obj(o, n) { | ||
return (n = Object.create(N)) && arguments[LEN] >= 1 ? copy(n, o) : n; | ||
return (n = Object.create(N)) && arguments.length >= 1 ? copy(n, o) : n; | ||
} | ||
@@ -142,4 +142,4 @@ function n8iv_proto(o) { | ||
function __type__() { | ||
var ctor = this[CTOR], nt = nativeType(this), t = ENV != CJS ? domType(nt) : re_global.test(nt) ? "global" : F; | ||
return t || (nt == OBJ && ctor[TYPE] != FN ? ctor[TYPE] || lc(ctor.n8ivName) || nt : nt); | ||
var ctor = this.constructor, nt = nativeType(this), t = ENV != CJS ? domType(nt) : re_global.test(nt) ? "global" : F; | ||
return t || (nt == "object" && ctor.__type__ != "function" ? ctor.__type__ || lc(ctor.n8ivName) || nt : nt); | ||
} | ||
@@ -150,3 +150,3 @@ function domType(t) { | ||
function n8iv_type(o) { | ||
return o === N || o === U ? F : o[TYPE] || (n8iv_proto(o) === N ? NOBJ : U); | ||
return o === N || o === U ? F : o.__type__ || (n8iv_proto(o) === N ? "nullobject" : U); | ||
} | ||
@@ -158,13 +158,13 @@ function nativeType(o, t) { | ||
function isBool(o) { | ||
return n8iv_type(o) == BOOL; | ||
return n8iv_type(o) == "boolean"; | ||
} | ||
function isEmpty(o) { | ||
switch (n8iv_type(o)) { | ||
case ARR: | ||
return !o[LEN]; | ||
case NUM: | ||
case "array": | ||
return !o.length; | ||
case "number": | ||
return isNaN(o); | ||
case OBJ: | ||
case "object": | ||
return !Object.len(o); | ||
case STR: | ||
case "string": | ||
return o === ""; | ||
@@ -176,21 +176,21 @@ default: | ||
function isFn(fn) { | ||
return typeof fn == FN; | ||
return typeof fn == "function"; | ||
} | ||
function isNum(o) { | ||
return n8iv_type(o) == NUM && !isNaN(o); | ||
return n8iv_type(o) == "number" && !isNaN(o); | ||
} | ||
function isObj(o, exclusive) { | ||
var t = n8iv_type(o); | ||
return t == OBJ && nativeType(o) == OBJ || exclusive !== T && t == NOBJ; | ||
return t == "object" && nativeType(o) == "object" || exclusive !== T && t == "nullobject"; | ||
} | ||
function isStr(o) { | ||
return n8iv_type(o) == STR; | ||
return n8iv_type(o) == "string"; | ||
} | ||
function isUndef(o) { | ||
return typeof o == UNDEF; | ||
return typeof o == "undefined"; | ||
} | ||
var F = !1, N = null, T = !0, U, ARR = "array", BOOL = "boolean", CJS = "commonjs", CTOR = "constructor", ERR = "error", EXPS = "exports", FN = "function", LEN = "length", NUM = "number", OBJ = "object", NOBJ = N + OBJ, PROTO = "prototype", STR = "string", TYPE = "__type__", UNDEF = "" + U, ENV = typeof module != UNDEF && EXPS in module ? CJS : typeof navigator != UNDEF ? "browser" : "other", OP = Object[PROTO], Module = ENV != CJS ? N : require("module"), booleans = [ 0, F, "", NaN, N, U ].map(String), coercions = [ F, NaN, N, T, U ].reduce(function(o, v) { | ||
var F = !1, N = null, T = !0, U, CJS = "commonjs", ENV = typeof module != "undefined" && "exports" in module ? CJS : typeof navigator != "undefined" ? "browser" : "other", OP = Object.prototype, Module = ENV != CJS ? N : require("module"), booleans = [ 0, F, "", NaN, N, U ].map(String), coercions = [ F, NaN, N, T, U ].reduce(function(o, v) { | ||
o[String(v)] = v; | ||
return o; | ||
}, n8iv_obj()), c = "c", cw = "cw", id_count = 999, id_prefix = "anon__", modes = function() { | ||
}, n8iv_obj()), id_count = 999, id_prefix = "anon__", modes = function() { | ||
var f = "configurable enumerable writable".split(" "), m = { | ||
@@ -215,3 +215,3 @@ ce : "ec", | ||
}, n8iv_obj()); | ||
!(k in m) || typeof m[k] == STR ? o[m[k]] = o[k] : m[k].forEach(function(f) { | ||
!(k in m) || typeof m[k] == "string" ? o[m[k]] = o[k] : m[k].forEach(function(f) { | ||
o[f] = o[k]; | ||
@@ -221,11 +221,11 @@ }); | ||
}, n8iv_obj()); | ||
delete v[UNDEF]; | ||
delete v.undefined; | ||
return v; | ||
}(), n8iv = n8iv_obj(), r = "r", re_col = /htmlcollection|nodelist/, re_el = /^html\w+?element$/, re_global = /global|window/i, re_n8iv = /^\u005E?n8iv/, re_type = /\[[^\s]+\s([^\]]+)\]/, re_vendor = /^[Ww]ebkit|[Mm]oz|O|[Mm]s|[Kk]html(.*)$/, slice = Array[PROTO].slice, types = { | ||
"[object Object]" : OBJ | ||
}(), n8iv = n8iv_obj(), re_col = /htmlcollection|nodelist/, re_el = /^html\w+?element$/, re_global = /global|window/i, re_n8iv = /^\u005E?n8iv/, re_type = /\[[^\s]+\s([^\]]+)\]/, re_vendor = /^[Ww]ebkit|[Mm]oz|O|[Mm]s|[Kk]html(.*)$/, slice = Array.prototype.slice, types = { | ||
"[object Object]" : "object" | ||
}; | ||
def(OP, TYPE, copy({ | ||
def(OP, "__type__", copy({ | ||
get : __type__ | ||
}, modes.r)); | ||
def(Array, "from", describe($A, r)); | ||
def(Array, "from", describe($A, "r")); | ||
defs(Object, { | ||
@@ -247,3 +247,3 @@ clone : function(o) { | ||
len : function(o) { | ||
return Object.keys(o)[LEN]; | ||
return Object.keys(o).length; | ||
}, | ||
@@ -273,10 +273,10 @@ remove : function(o, keys) { | ||
} | ||
}, r); | ||
def(Array[PROTO], "find", describe(function(fn, ctx) { | ||
var i = -1, l = this[LEN] >>> 0; | ||
}, "r"); | ||
def(Array.prototype, "find", describe(function(fn, ctx) { | ||
var i = -1, l = this.length >>> 0; | ||
ctx || (ctx = this); | ||
while (++i < l) if (!!fn.call(ctx, this[i], i, this)) return this[i]; | ||
return N; | ||
}, r)); | ||
defs(Function[PROTO], { | ||
}, "r")); | ||
defs(Function.prototype, { | ||
n8ivName : { | ||
@@ -298,3 +298,3 @@ get : function() { | ||
}, fn = this; | ||
bound[PROTO] = Object.create(fn[PROTO]); | ||
bound.prototype = Object.create(fn.prototype); | ||
return bound.mimic(fn); | ||
@@ -304,15 +304,15 @@ }, | ||
return Object.defineProperties(this, { | ||
displayName : describe(name || fn.n8ivName, c), | ||
displayName : describe(name || fn.n8ivName, "c"), | ||
toString : describe(function() { | ||
return fn.valueOf().toString(); | ||
}, c), | ||
}, "c"), | ||
valueOf : describe(function() { | ||
return fn; | ||
}, c) | ||
}, "c") | ||
}); | ||
} | ||
}, r); | ||
defs(String[PROTO], { | ||
}, "r"); | ||
defs(String.prototype, { | ||
endsWith : function(s) { | ||
return this[LEN] && this.lastIndexOf(s) == this[LEN] - s[LEN]; | ||
return this.length && this.lastIndexOf(s) == this.length - s.length; | ||
}, | ||
@@ -325,7 +325,7 @@ lc : function() { | ||
} | ||
}, r); | ||
typeof global == UNDEF || (root = global); | ||
}, "r"); | ||
typeof global == "undefined" || (root = global); | ||
ENV != CJS ? def(root, "n8iv", describe({ | ||
value : n8iv | ||
}, r)) : module[EXPS] = n8iv; | ||
}, "r")) : module.exports = n8iv; | ||
defs(n8iv, { | ||
@@ -367,4 +367,4 @@ ENV : ENV, | ||
valof : valof | ||
}, r); | ||
}, "r"); | ||
return n8iv; | ||
})(this); |
!function(n8iv) { | ||
var LEN = "length", PROTO = "prototype", F = !1, N = null, T = !0, r = "r"; | ||
var F = !1, N = null, T = !0; | ||
function aggregate(o, val, fn, ctx) { | ||
@@ -27,3 +27,3 @@ ctx || (ctx = o); | ||
function arraysEqual(a1, a2) { | ||
return a1[LEN] == a2[LEN] && Array.from(a1).every(function(v, i) { | ||
return a1.length == a2.length && Array.from(a1).every(function(v, i) { | ||
return equalTo(a2[i], v); | ||
@@ -41,3 +41,3 @@ }); | ||
function ownLen(o) { | ||
return ownKeys(o)[LEN]; | ||
return ownKeys(o).length; | ||
} | ||
@@ -56,4 +56,4 @@ function reduce(o, fn, val) { | ||
reduce : reduce | ||
}, r); | ||
n8iv.defs(Function[PROTO], function() { | ||
}, "r"); | ||
n8iv.defs(Function.prototype, function() { | ||
var re_args = /^[\s\(]*function[^\(]*\(([^\)]*)\)/, re_split = /\s*,\s*/; | ||
@@ -64,3 +64,3 @@ n8iv.def(Function, "from", n8iv.describe(function from(o) { | ||
}; | ||
}, r)); | ||
}, "r")); | ||
return { | ||
@@ -70,3 +70,3 @@ params : { | ||
var names = String(this).match(re_args)[1].trim().split(re_split); | ||
return names[LEN] == 1 && !names[0] ? [] : names; | ||
return names.length == 1 && !names[0] ? [] : names; | ||
} | ||
@@ -88,3 +88,3 @@ }, | ||
return fn.apply(this, [ this ].concat(Array.from(arguments))); | ||
}.mimic(fn), r)) || fn[baked]; | ||
}.mimic(fn), "r")) || fn[baked]; | ||
}, | ||
@@ -136,4 +136,4 @@ defer : n8iv.ENV == "commonjs" ? function(ctx) { | ||
}; | ||
}(), r); | ||
n8iv.defs(Array[PROTO], function() { | ||
}(), "r"); | ||
n8iv.defs(Array.prototype, function() { | ||
function groupByFn(field, v) { | ||
@@ -157,3 +157,3 @@ return field(v) ? 0 : 1; | ||
} | ||
var AP = Array[PROTO], sort = { | ||
var AP = Array.prototype, sort = { | ||
desc : function(a, b) { | ||
@@ -170,3 +170,3 @@ return a[1] == b[1] ? 0 : a[1] < b[1] ? 1 : -1; | ||
value : sort | ||
}, r)); | ||
}, "r")); | ||
return { | ||
@@ -187,3 +187,3 @@ aggregate : function(val, fn, ctx) { | ||
clear : function() { | ||
this[LEN] = 0; | ||
this.length = 0; | ||
return this; | ||
@@ -209,3 +209,3 @@ }, | ||
return AP.aggregate.call(this, [], function(v, o, i) { | ||
Array.isArray(o) ? v.splice.apply(v, [ v[LEN], 0 ].concat(o.flatten(n))) : v.push(o); | ||
Array.isArray(o) ? v.splice.apply(v, [ v.length, 0 ].concat(o.flatten(n))) : v.push(o); | ||
return v; | ||
@@ -266,6 +266,6 @@ }, this); | ||
item : function(i) { | ||
return this[i < 0 ? this[LEN] + i : i]; | ||
return this[i < 0 ? this.length + i : i]; | ||
}, | ||
last : function() { | ||
return this[this[LEN] - 1]; | ||
return this[this.length - 1]; | ||
}, | ||
@@ -317,3 +317,3 @@ mapc : function(fn, ctx) { | ||
}; | ||
}(), r); | ||
}(), "r"); | ||
n8iv.defs(Number, function() { | ||
@@ -333,6 +333,6 @@ var abs = Math.abs, big_int = 9007199254740992, floor = Math.floor; | ||
}(), "cw"); | ||
n8iv.defs(Number[PROTO], { | ||
n8iv.defs(Number.prototype, { | ||
pad : function(l, radix) { | ||
var s = this.toString(radix || 10); | ||
return "0".times(l - s[LEN]) + s; | ||
return "0".times(l - s.length) + s; | ||
}, | ||
@@ -346,4 +346,4 @@ times : function(fn, ctx) { | ||
} | ||
}, r); | ||
n8iv.defs(String[PROTO], function() { | ||
}, "r"); | ||
n8iv.defs(String.prototype, function() { | ||
var cache_chars = n8iv.obj(), cache_slices = n8iv.obj(), esc_chars = /([-\*\+\?\.\|\^\$\/\\\(\)[\]\{\}])/g, esc_val = "\\$1", re_caps = /([A-Z])/g, re_gsub = /\$?\{([^\}]+)\}/g, re_hex = /#?(\w{1,6})/, re_rgb = /(\d{1,3})/g, re_split_string = /[\sA-Z_-]+/g; | ||
@@ -401,3 +401,3 @@ function _splitString(m, p) { | ||
var m = Array.from(this.match(re)); | ||
switch (m[LEN]) { | ||
switch (m.length) { | ||
case 1: | ||
@@ -418,3 +418,3 @@ if (m[0] === N || m[0] === this) return []; | ||
n = parseInt(n, 10); | ||
if (isNaN(n) || this[LEN] < n || n == 0) return [ String(this) ]; | ||
if (isNaN(n) || this.length < n || n == 0) return [ String(this) ]; | ||
return this.match(cache_slices[n] || (cache_slices[n] = new RegExp("(.{1," + n + "})", "g"))); | ||
@@ -438,3 +438,3 @@ }, | ||
var m = this.match(re_rgb); | ||
return "#" + (m[LEN] == 1 ? toHex(m[0]).times(3) : m.map(toHex).join("")); | ||
return "#" + (m.length == 1 ? toHex(m[0]).times(3) : m.map(toHex).join("")); | ||
}; | ||
@@ -446,3 +446,3 @@ }(), | ||
toRGB : function(as_array) { | ||
var o = this.match(re_hex)[1], l = o[LEN], v; | ||
var o = this.match(re_hex)[1], l = o.length, v; | ||
switch (l) { | ||
@@ -468,3 +468,3 @@ case 6: | ||
n8iv.isStr(c) || (c = "..."); | ||
return this[LEN] < i ? String(this) : this.substring(0, i).trimRight() + c; | ||
return this.length < i ? String(this) : this.substring(0, i).trimRight() + c; | ||
}, | ||
@@ -478,4 +478,4 @@ uc : function() { | ||
}; | ||
}(), r); | ||
}(), "r"); | ||
n8iv.ENV != "commonjs" || module.exports === n8iv || (module.exports = n8iv); | ||
}(typeof n8iv != "undefined" ? n8iv : typeof require != "undefined" ? require("./n8iv._") : N); |
283
n8iv.js
!function() { | ||
var n8iv = function(root) { | ||
function $A(a, i, j) { | ||
return got(a, LEN) ? slice.call(a, isNum(i) ? i > 0 ? i : 0 : 0, isNum(j) ? j > i ? j : i + 1 : a[LEN]) : [ a ]; | ||
return got(a, "length") ? slice.call(a, isNum(i) ? i > 0 ? i : 0 : 0, isNum(j) ? j > i ? j : i + 1 : a.length) : [ a ]; | ||
} | ||
function bless(ns, ctx) { | ||
switch (n8iv_type(ns)) { | ||
case ARR: | ||
case "array": | ||
break; | ||
case STR: | ||
case "string": | ||
ns = ns.split("."); | ||
@@ -20,3 +20,3 @@ break; | ||
} | ||
if (!ns[LEN]) return blessCTX(ctx); | ||
if (!ns.length) return blessCTX(ctx); | ||
!ns[0].startsWith("^") || (ctx ? ns.shift() : ns[0] = ns[0].substring(1)); | ||
@@ -32,3 +32,3 @@ ctx = blessCTX(ctx); | ||
function blessCTX(ctx) { | ||
if (ENV == CJS) return ctx ? ctx instanceof Module ? ctx[EXPS] : ctx : module[EXPS]; else return ctx || root; | ||
if (ENV == CJS) return ctx ? ctx instanceof Module ? ctx.exports : ctx : module.exports; else return ctx || root; | ||
} | ||
@@ -39,7 +39,7 @@ function bool(o) { | ||
return F; | ||
case BOOL: | ||
case "boolean": | ||
return o; | ||
case NUM: | ||
case "number": | ||
return o !== 0 && !isNaN(o); | ||
case STR: | ||
case "string": | ||
return !booleans.some(function(v) { | ||
@@ -63,7 +63,7 @@ return v === o; | ||
!(desc.get || desc.set) || delete desc.writable; | ||
if (overwrite === T || !exists) Object.defineProperty(item, name, desc); else if (debug === T && exists) trace().error(new Error("Trying to overwrite existing property: " + name + ", in: " + (isFn(item) ? item.n8ivName : item[CTOR].n8ivName) + "."), T); | ||
if (overwrite === T || !exists) Object.defineProperty(item, name, desc); else if (debug === T && exists) trace().error(new Error("Trying to overwrite existing property: " + name + ", in: " + (isFn(item) ? item.n8ivName : item.constructor.n8ivName) + "."), T); | ||
return n8iv; | ||
} | ||
function defs(item, o, m, overwrite, debug) { | ||
m || (m = cw); | ||
m || (m = "cw"); | ||
for (var k in o) !has(o, k) || def(item, k, describe(o[k], m), overwrite, debug); | ||
@@ -83,6 +83,6 @@ return n8iv; | ||
switch (n8iv_type(e)) { | ||
case ERR: | ||
case "error": | ||
msg = e.message; | ||
break; | ||
case STR: | ||
case "string": | ||
msg = String(e); | ||
@@ -92,3 +92,3 @@ e = new Error(e); | ||
} | ||
!(ERR in console) || console.error(msg); | ||
!("error" in console) || console.error(msg); | ||
if (chuck === T) throw e; | ||
@@ -98,3 +98,3 @@ return n8iv; | ||
function exists(o) { | ||
return o !== N && o !== U && (typeof o == NUM ? !isNaN(o) : T); | ||
return o !== N && o !== U && (typeof o == "number" ? !isNaN(o) : T); | ||
} | ||
@@ -117,3 +117,3 @@ function got(o, k) { | ||
function n8iv_obj(o, n) { | ||
return (n = Object.create(N)) && arguments[LEN] >= 1 ? copy(n, o) : n; | ||
return (n = Object.create(N)) && arguments.length >= 1 ? copy(n, o) : n; | ||
} | ||
@@ -143,4 +143,4 @@ function n8iv_proto(o) { | ||
function __type__() { | ||
var ctor = this[CTOR], nt = nativeType(this), t = ENV != CJS ? domType(nt) : re_global.test(nt) ? "global" : F; | ||
return t || (nt == OBJ && ctor[TYPE] != FN ? ctor[TYPE] || lc(ctor.n8ivName) || nt : nt); | ||
var ctor = this.constructor, nt = nativeType(this), t = ENV != CJS ? domType(nt) : re_global.test(nt) ? "global" : F; | ||
return t || (nt == "object" && ctor.__type__ != "function" ? ctor.__type__ || lc(ctor.n8ivName) || nt : nt); | ||
} | ||
@@ -151,3 +151,3 @@ function domType(t) { | ||
function n8iv_type(o) { | ||
return o === N || o === U ? F : o[TYPE] || (n8iv_proto(o) === N ? NOBJ : U); | ||
return o === N || o === U ? F : o.__type__ || (n8iv_proto(o) === N ? "nullobject" : U); | ||
} | ||
@@ -159,13 +159,13 @@ function nativeType(o, t) { | ||
function isBool(o) { | ||
return n8iv_type(o) == BOOL; | ||
return n8iv_type(o) == "boolean"; | ||
} | ||
function isEmpty(o) { | ||
switch (n8iv_type(o)) { | ||
case ARR: | ||
return !o[LEN]; | ||
case NUM: | ||
case "array": | ||
return !o.length; | ||
case "number": | ||
return isNaN(o); | ||
case OBJ: | ||
case "object": | ||
return !Object.len(o); | ||
case STR: | ||
case "string": | ||
return o === ""; | ||
@@ -177,21 +177,21 @@ default: | ||
function isFn(fn) { | ||
return typeof fn == FN; | ||
return typeof fn == "function"; | ||
} | ||
function isNum(o) { | ||
return n8iv_type(o) == NUM && !isNaN(o); | ||
return n8iv_type(o) == "number" && !isNaN(o); | ||
} | ||
function isObj(o, exclusive) { | ||
var t = n8iv_type(o); | ||
return t == OBJ && nativeType(o) == OBJ || exclusive !== T && t == NOBJ; | ||
return t == "object" && nativeType(o) == "object" || exclusive !== T && t == "nullobject"; | ||
} | ||
function isStr(o) { | ||
return n8iv_type(o) == STR; | ||
return n8iv_type(o) == "string"; | ||
} | ||
function isUndef(o) { | ||
return typeof o == UNDEF; | ||
return typeof o == "undefined"; | ||
} | ||
var F = !1, N = null, T = !0, U, ARR = "array", BOOL = "boolean", CJS = "commonjs", CTOR = "constructor", ERR = "error", EXPS = "exports", FN = "function", LEN = "length", NUM = "number", OBJ = "object", NOBJ = N + OBJ, PROTO = "prototype", STR = "string", TYPE = "__type__", UNDEF = "" + U, ENV = typeof module != UNDEF && EXPS in module ? CJS : typeof navigator != UNDEF ? "browser" : "other", OP = Object[PROTO], Module = ENV != CJS ? N : require("module"), booleans = [ 0, F, "", NaN, N, U ].map(String), coercions = [ F, NaN, N, T, U ].reduce(function(o, v) { | ||
var F = !1, N = null, T = !0, U, CJS = "commonjs", ENV = typeof module != "undefined" && "exports" in module ? CJS : typeof navigator != "undefined" ? "browser" : "other", OP = Object.prototype, Module = ENV != CJS ? N : require("module"), booleans = [ 0, F, "", NaN, N, U ].map(String), coercions = [ F, NaN, N, T, U ].reduce(function(o, v) { | ||
o[String(v)] = v; | ||
return o; | ||
}, n8iv_obj()), c = "c", cw = "cw", id_count = 999, id_prefix = "anon__", modes = function() { | ||
}, n8iv_obj()), id_count = 999, id_prefix = "anon__", modes = function() { | ||
var f = "configurable enumerable writable".split(" "), m = { | ||
@@ -216,3 +216,3 @@ ce : "ec", | ||
}, n8iv_obj()); | ||
!(k in m) || typeof m[k] == STR ? o[m[k]] = o[k] : m[k].forEach(function(f) { | ||
!(k in m) || typeof m[k] == "string" ? o[m[k]] = o[k] : m[k].forEach(function(f) { | ||
o[f] = o[k]; | ||
@@ -222,11 +222,11 @@ }); | ||
}, n8iv_obj()); | ||
delete v[UNDEF]; | ||
delete v.undefined; | ||
return v; | ||
}(), n8iv = n8iv_obj(), r = "r", re_col = /htmlcollection|nodelist/, re_el = /^html\w+?element$/, re_global = /global|window/i, re_n8iv = /^\u005E?n8iv/, re_type = /\[[^\s]+\s([^\]]+)\]/, re_vendor = /^[Ww]ebkit|[Mm]oz|O|[Mm]s|[Kk]html(.*)$/, slice = Array[PROTO].slice, types = { | ||
"[object Object]" : OBJ | ||
}(), n8iv = n8iv_obj(), re_col = /htmlcollection|nodelist/, re_el = /^html\w+?element$/, re_global = /global|window/i, re_n8iv = /^\u005E?n8iv/, re_type = /\[[^\s]+\s([^\]]+)\]/, re_vendor = /^[Ww]ebkit|[Mm]oz|O|[Mm]s|[Kk]html(.*)$/, slice = Array.prototype.slice, types = { | ||
"[object Object]" : "object" | ||
}; | ||
def(OP, TYPE, copy({ | ||
def(OP, "__type__", copy({ | ||
get : __type__ | ||
}, modes.r)); | ||
def(Array, "from", describe($A, r)); | ||
def(Array, "from", describe($A, "r")); | ||
defs(Object, { | ||
@@ -248,3 +248,3 @@ clone : function(o) { | ||
len : function(o) { | ||
return Object.keys(o)[LEN]; | ||
return Object.keys(o).length; | ||
}, | ||
@@ -274,10 +274,10 @@ remove : function(o, keys) { | ||
} | ||
}, r); | ||
def(Array[PROTO], "find", describe(function(fn, ctx) { | ||
var i = -1, l = this[LEN] >>> 0; | ||
}, "r"); | ||
def(Array.prototype, "find", describe(function(fn, ctx) { | ||
var i = -1, l = this.length >>> 0; | ||
ctx || (ctx = this); | ||
while (++i < l) if (!!fn.call(ctx, this[i], i, this)) return this[i]; | ||
return N; | ||
}, r)); | ||
defs(Function[PROTO], { | ||
}, "r")); | ||
defs(Function.prototype, { | ||
n8ivName : { | ||
@@ -299,3 +299,3 @@ get : function() { | ||
}, fn = this; | ||
bound[PROTO] = Object.create(fn[PROTO]); | ||
bound.prototype = Object.create(fn.prototype); | ||
return bound.mimic(fn); | ||
@@ -305,15 +305,15 @@ }, | ||
return Object.defineProperties(this, { | ||
displayName : describe(name || fn.n8ivName, c), | ||
displayName : describe(name || fn.n8ivName, "c"), | ||
toString : describe(function() { | ||
return fn.valueOf().toString(); | ||
}, c), | ||
}, "c"), | ||
valueOf : describe(function() { | ||
return fn; | ||
}, c) | ||
}, "c") | ||
}); | ||
} | ||
}, r); | ||
defs(String[PROTO], { | ||
}, "r"); | ||
defs(String.prototype, { | ||
endsWith : function(s) { | ||
return this[LEN] && this.lastIndexOf(s) == this[LEN] - s[LEN]; | ||
return this.length && this.lastIndexOf(s) == this.length - s.length; | ||
}, | ||
@@ -326,7 +326,7 @@ lc : function() { | ||
} | ||
}, r); | ||
typeof global == UNDEF || (root = global); | ||
}, "r"); | ||
typeof global == "undefined" || (root = global); | ||
ENV != CJS ? def(root, "n8iv", describe({ | ||
value : n8iv | ||
}, r)) : module[EXPS] = n8iv; | ||
}, "r")) : module.exports = n8iv; | ||
defs(n8iv, { | ||
@@ -368,6 +368,6 @@ ENV : ENV, | ||
valof : valof | ||
}, r); | ||
}, "r"); | ||
return n8iv; | ||
}(this); | ||
var LEN = "length", PROTO = "prototype", F = !1, N = null, T = !0, r = "r"; | ||
var F = !1, N = null, T = !0; | ||
function aggregate(o, val, fn, ctx) { | ||
@@ -397,3 +397,3 @@ ctx || (ctx = o); | ||
function arraysEqual(a1, a2) { | ||
return a1[LEN] == a2[LEN] && Array.from(a1).every(function(v, i) { | ||
return a1.length == a2.length && Array.from(a1).every(function(v, i) { | ||
return equalTo(a2[i], v); | ||
@@ -411,3 +411,3 @@ }); | ||
function ownLen(o) { | ||
return ownKeys(o)[LEN]; | ||
return ownKeys(o).length; | ||
} | ||
@@ -426,4 +426,4 @@ function reduce(o, fn, val) { | ||
reduce : reduce | ||
}, r); | ||
n8iv.defs(Function[PROTO], function() { | ||
}, "r"); | ||
n8iv.defs(Function.prototype, function() { | ||
var re_args = /^[\s\(]*function[^\(]*\(([^\)]*)\)/, re_split = /\s*,\s*/; | ||
@@ -434,3 +434,3 @@ n8iv.def(Function, "from", n8iv.describe(function from(o) { | ||
}; | ||
}, r)); | ||
}, "r")); | ||
return { | ||
@@ -440,3 +440,3 @@ params : { | ||
var names = String(this).match(re_args)[1].trim().split(re_split); | ||
return names[LEN] == 1 && !names[0] ? [] : names; | ||
return names.length == 1 && !names[0] ? [] : names; | ||
} | ||
@@ -458,3 +458,3 @@ }, | ||
return fn.apply(this, [ this ].concat(Array.from(arguments))); | ||
}.mimic(fn), r)) || fn[baked]; | ||
}.mimic(fn), "r")) || fn[baked]; | ||
}, | ||
@@ -506,4 +506,4 @@ defer : n8iv.ENV == "commonjs" ? function(ctx) { | ||
}; | ||
}(), r); | ||
n8iv.defs(Array[PROTO], function() { | ||
}(), "r"); | ||
n8iv.defs(Array.prototype, function() { | ||
function groupByFn(field, v) { | ||
@@ -527,3 +527,3 @@ return field(v) ? 0 : 1; | ||
} | ||
var AP = Array[PROTO], sort = { | ||
var AP = Array.prototype, sort = { | ||
desc : function(a, b) { | ||
@@ -540,3 +540,3 @@ return a[1] == b[1] ? 0 : a[1] < b[1] ? 1 : -1; | ||
value : sort | ||
}, r)); | ||
}, "r")); | ||
return { | ||
@@ -557,3 +557,3 @@ aggregate : function(val, fn, ctx) { | ||
clear : function() { | ||
this[LEN] = 0; | ||
this.length = 0; | ||
return this; | ||
@@ -579,3 +579,3 @@ }, | ||
return AP.aggregate.call(this, [], function(v, o, i) { | ||
Array.isArray(o) ? v.splice.apply(v, [ v[LEN], 0 ].concat(o.flatten(n))) : v.push(o); | ||
Array.isArray(o) ? v.splice.apply(v, [ v.length, 0 ].concat(o.flatten(n))) : v.push(o); | ||
return v; | ||
@@ -636,6 +636,6 @@ }, this); | ||
item : function(i) { | ||
return this[i < 0 ? this[LEN] + i : i]; | ||
return this[i < 0 ? this.length + i : i]; | ||
}, | ||
last : function() { | ||
return this[this[LEN] - 1]; | ||
return this[this.length - 1]; | ||
}, | ||
@@ -687,3 +687,3 @@ mapc : function(fn, ctx) { | ||
}; | ||
}(), r); | ||
}(), "r"); | ||
n8iv.defs(Number, function() { | ||
@@ -703,6 +703,6 @@ var abs = Math.abs, big_int = 9007199254740992, floor = Math.floor; | ||
}(), "cw"); | ||
n8iv.defs(Number[PROTO], { | ||
n8iv.defs(Number.prototype, { | ||
pad : function(l, radix) { | ||
var s = this.toString(radix || 10); | ||
return "0".times(l - s[LEN]) + s; | ||
return "0".times(l - s.length) + s; | ||
}, | ||
@@ -716,4 +716,4 @@ times : function(fn, ctx) { | ||
} | ||
}, r); | ||
n8iv.defs(String[PROTO], function() { | ||
}, "r"); | ||
n8iv.defs(String.prototype, function() { | ||
var cache_chars = n8iv.obj(), cache_slices = n8iv.obj(), esc_chars = /([-\*\+\?\.\|\^\$\/\\\(\)[\]\{\}])/g, esc_val = "\\$1", re_caps = /([A-Z])/g, re_gsub = /\$?\{([^\}]+)\}/g, re_hex = /#?(\w{1,6})/, re_rgb = /(\d{1,3})/g, re_split_string = /[\sA-Z_-]+/g; | ||
@@ -771,3 +771,3 @@ function _splitString(m, p) { | ||
var m = Array.from(this.match(re)); | ||
switch (m[LEN]) { | ||
switch (m.length) { | ||
case 1: | ||
@@ -788,3 +788,3 @@ if (m[0] === N || m[0] === this) return []; | ||
n = parseInt(n, 10); | ||
if (isNaN(n) || this[LEN] < n || n == 0) return [ String(this) ]; | ||
if (isNaN(n) || this.length < n || n == 0) return [ String(this) ]; | ||
return this.match(cache_slices[n] || (cache_slices[n] = new RegExp("(.{1," + n + "})", "g"))); | ||
@@ -808,3 +808,3 @@ }, | ||
var m = this.match(re_rgb); | ||
return "#" + (m[LEN] == 1 ? toHex(m[0]).times(3) : m.map(toHex).join("")); | ||
return "#" + (m.length == 1 ? toHex(m[0]).times(3) : m.map(toHex).join("")); | ||
}; | ||
@@ -816,3 +816,3 @@ }(), | ||
toRGB : function(as_array) { | ||
var o = this.match(re_hex)[1], l = o[LEN], v; | ||
var o = this.match(re_hex)[1], l = o.length, v; | ||
switch (l) { | ||
@@ -838,3 +838,3 @@ case 6: | ||
n8iv.isStr(c) || (c = "..."); | ||
return this[LEN] < i ? String(this) : this.substring(0, i).trimRight() + c; | ||
return this.length < i ? String(this) : this.substring(0, i).trimRight() + c; | ||
}, | ||
@@ -848,4 +848,4 @@ uc : function() { | ||
}; | ||
}(), r); | ||
var F = !1, N = null, T = !0, U, cw = "cw", r = "r", ARR = "array", CTOR = "constructor", FN = "function", LEN = "length", OBJ = "object", NOBJ = N + OBJ, PROTO = "prototype", TYPE = "__type__"; | ||
}(), "r"); | ||
var F = !1, N = null, T = !0, U; | ||
!function() { | ||
@@ -859,3 +859,3 @@ function Class(path, desc) { | ||
!n8iv.isStr(_super) || (_super = reg_path[_super] || reg_type[_super]); | ||
_ctor = desc[CTOR] !== Object ? desc[CTOR] : _super; | ||
_ctor = desc.constructor !== Object ? desc.constructor : _super; | ||
if (path) { | ||
@@ -866,10 +866,10 @@ ns = path.split("."); | ||
} | ||
n8iv.def(_proto, PARENT, n8iv.describe(n8iv.noop, cw), T); | ||
n8iv.def(_proto, CTOR, n8iv.describe(ctor(_ctor, _super[PROTO][CTOR], name, _proto), r), T); | ||
C = _proto[CTOR]; | ||
n8iv.def(C, TYPE, n8iv.describe("class", r), T); | ||
n8iv.def(_proto, TYPE, n8iv.describe(type, r), T); | ||
n8iv.def(_proto, "parent", n8iv.describe(n8iv.noop, "cw"), T); | ||
n8iv.def(_proto, "constructor", n8iv.describe(ctor(_ctor, _super.prototype.constructor, name, _proto), "r"), T); | ||
C = _proto.constructor; | ||
n8iv.def(C, "__type__", n8iv.describe("class", "r"), T); | ||
n8iv.def(_proto, "__type__", n8iv.describe(type, "r"), T); | ||
Object.remove(desc, defaults); | ||
C[PROTO] = apply(_proto, n8iv.copy(desc, mixin)); | ||
n8iv.def(C, "create", n8iv.describe(create(extend(C, _super)), r), T); | ||
C.prototype = apply(_proto, n8iv.copy(desc, mixin)); | ||
n8iv.def(C, "create", n8iv.describe(create(extend(C, _super)), "r"), T); | ||
path = path.replace(re_root, ""); | ||
@@ -879,3 +879,3 @@ if (singleton) { | ||
value : singleton === T ? new C : C.create.apply(C, [].concat(singleton)) | ||
}, r)); | ||
}, "r")); | ||
register(C, path, type); | ||
@@ -886,3 +886,3 @@ C = C.singleton; | ||
value : C | ||
}, r)); | ||
}, "r")); | ||
return C; | ||
@@ -893,3 +893,3 @@ } | ||
switch (n8iv.type(v)) { | ||
case OBJ: | ||
case "object": | ||
n8iv.def(proto, k, v, T); | ||
@@ -905,3 +905,3 @@ break; | ||
return function create() { | ||
return singleton(C) || C.apply(Object.create(C[PROTO]), arguments); | ||
return singleton(C) || C.apply(Object.create(C.prototype), arguments); | ||
}; | ||
@@ -916,8 +916,8 @@ } | ||
function extend(C, Sup) { | ||
if (!(SUPER in C[PROTO])) { | ||
var p = C[PROTO], sp = Sup[PROTO]; | ||
if (!("__super" in C.prototype)) { | ||
var p = C.prototype, sp = Sup.prototype; | ||
Object.keys(sp).forEach(function(k) { | ||
if (k in reserved) return; | ||
switch (n8iv.type(sp[k])) { | ||
case FN: | ||
case "function": | ||
p[k] = !n8iv.isFn(p[k]) ? wrap(sp[k], n8iv.noop, k) : wrap(p[k], sp[k], k); | ||
@@ -933,6 +933,6 @@ break; | ||
sp = n8iv.describe({ | ||
value : Object.create(Sup[PROTO]) | ||
}, r); | ||
n8iv.def(C, SUPER, sp); | ||
n8iv.def(C[PROTO], SUPER, sp); | ||
value : Object.create(Sup.prototype) | ||
}, "r"); | ||
n8iv.def(C, "__super", sp); | ||
n8iv.def(C.prototype, "__super", sp); | ||
} | ||
@@ -946,6 +946,6 @@ return C; | ||
if (o instanceof C) return T; | ||
if (!(o = o[CTOR])) return F; | ||
if (!(o = o.constructor)) return F; | ||
do { | ||
if (o === C) return T; | ||
} while (o[SUPER] && (o = o[SUPER][CTOR])); | ||
} while (o.__super && (o = o.__super.constructor)); | ||
return F; | ||
@@ -957,3 +957,3 @@ } | ||
!type || !(type in reg_type) || msg.push(err_msg + "Type"); | ||
if (msg[LEN]) { | ||
if (msg.length) { | ||
n8iv.trace(); | ||
@@ -969,3 +969,3 @@ msg.forEach(n8iv.error); | ||
function type(c) { | ||
var ctor = c[CTOR], k; | ||
var ctor = c.constructor, k; | ||
for (k in reg_path) if (reg_path[k] === ctor) return k; | ||
@@ -976,22 +976,22 @@ return N; | ||
return function() { | ||
var o, p = n8iv.description(this, PARENT) || desc_noop; | ||
var o, p = n8iv.description(this, "parent") || desc_noop; | ||
p.writable = T; | ||
n8iv.def(this, PARENT, s ? n8iv.describe(s, cw) : desc_noop, T); | ||
n8iv.def(this, "parent", s ? n8iv.describe(s, "cw") : desc_noop, T); | ||
o = m.apply(this, arguments); | ||
n8iv.def(this, PARENT, p, T); | ||
n8iv.def(this, "parent", p, T); | ||
return this.chain !== F && o === U ? this : o; | ||
}.mimic(m, name); | ||
} | ||
var ERR_MSG = " already exists. Cannot override existing ", PARENT = "parent", SUPER = "__super", defaults = (CTOR + " extend mixin module singleton type").split(" "), desc_noop = n8iv.describe(n8iv.noop, cw), dumb = n8iv.obj(), re_dot = /\./g, re_root = /^\u005E/, reg_path = n8iv.obj(), reg_type = n8iv.obj(), reserved = n8iv.obj(); | ||
reserved[CTOR] = reserved[PARENT] = reserved[SUPER] = reserved[TYPE] = T; | ||
n8iv.def(Class, "is", n8iv.describe(is, r)).def(Class, "type", n8iv.describe(type, r)).def(n8iv, "Class", n8iv.describe(Class, r)).def(n8iv, "create", n8iv.describe(function(n) { | ||
var ERR_MSG = " already exists. Cannot override existing ", defaults = "constructor extend mixin module singleton type".split(" "), desc_noop = n8iv.describe(n8iv.noop, "cw"), dumb = n8iv.obj(), re_dot = /\./g, re_root = /^\u005E/, reg_path = n8iv.obj(), reg_type = n8iv.obj(), reserved = n8iv.obj(); | ||
reserved.constructor = reserved.parent = reserved.__super = reserved.__type__ = T; | ||
n8iv.def(Class, "is", n8iv.describe(is, "r")).def(Class, "type", n8iv.describe(type, "r")).def(n8iv, "Class", n8iv.describe(Class, "r")).def(n8iv, "create", n8iv.describe(function(n) { | ||
var C = reg_type[n] || reg_type["n8iv_" + n] || reg_path[n], args = Array.from(arguments, 1); | ||
C || n8iv.trace().error(new Error(n + " does not match any registered n8iv.Classes."), T); | ||
return C.create.apply(n8iv.global, args); | ||
}, r)); | ||
}, "r")); | ||
}(); | ||
n8iv.Class("n8iv.Callback", function() { | ||
n8iv.def(Function[PROTO], "callback", n8iv.describe(function(conf) { | ||
n8iv.def(Function.prototype, "callback", n8iv.describe(function(conf) { | ||
return (new n8iv.Callback(this, conf)).fire.mimic(this); | ||
}, r)); | ||
}, "r")); | ||
function buffer() { | ||
@@ -1009,7 +1009,7 @@ if (bid in this) return this; | ||
} | ||
var bid = "bufferId", he = "handleEvent"; | ||
var bid = "bufferId", he = "handleEvent", tid = "timeoutId"; | ||
return { | ||
constructor : function Callback(fn, conf) { | ||
n8iv.copy(this, conf || n8iv.obj()); | ||
var desc = n8iv.describe(N, r), fire = (n8iv.isNum(this.buffer) ? buffer : this.exec).bind(this); | ||
var desc = n8iv.describe(N, "r"), fire = (n8iv.isNum(this.buffer) ? buffer : this.exec).bind(this); | ||
desc.value = fn; | ||
@@ -1043,5 +1043,7 @@ n8iv.def(this, "fn", desc); | ||
this.times === 0 || this.times > ++this.count || this.disable(); | ||
var a = Array.from(arguments), ctx = this.ctx, ms = this.delay, t = n8iv.type(a[0]), v; | ||
t && (t.endsWith("event") || t == "n8iv_observer") ? a.splice.apply(a, [ 1, 0 ].concat(this.args)) : a.unshift.apply(a, this.args); | ||
ms === N ? v = this.fn.apply(ctx, a) : this.fn.delay.apply(this.fn, [ ms, ctx ].concat(a)); | ||
var a = Array.from(arguments), me = this, ctx = me.ctx, ms = me.delay, t = n8iv.type(a[0]), v; | ||
t && (t.endsWith("event") || t == "n8iv_observer") ? a.splice.apply(a, [ 1, 0 ].concat(me.args)) : a.unshift.apply(a, me.args); | ||
ms === N ? v = me.fn.apply(ctx, a) : this[tid] = setTimeout(function() { | ||
me.fn.apply(ctx, a); | ||
}, ms); | ||
return v; | ||
@@ -1052,2 +1054,5 @@ }, | ||
buffer_stop.call(this.enable()); | ||
}, | ||
stop : function() { | ||
!(tid in this) || clearTimeout(this[tid]), delete this[tid]; | ||
} | ||
@@ -1060,3 +1065,3 @@ }; | ||
constructor : function Hash(o) { | ||
n8iv.def(this, ID, n8iv.describe(cache.push(n8iv.obj()) - 1, r)); | ||
n8iv.def(this, ID, n8iv.describe(cache.push(n8iv.obj()) - 1, "r")); | ||
!n8iv.isObj(o) || this.set(o); | ||
@@ -1071,3 +1076,3 @@ }, | ||
get : function() { | ||
return this.keys[LEN]; | ||
return this.keys.length; | ||
} | ||
@@ -1121,4 +1126,4 @@ }, | ||
switch (n8iv.type(o)) { | ||
case OBJ: | ||
case NOBJ: | ||
case "object": | ||
case "nullobject": | ||
Object.keys(o).forEach(function(k) { | ||
@@ -1153,14 +1158,14 @@ this.set(k, o[k]); | ||
switch (n8iv.type(l)) { | ||
case FN: | ||
case "function": | ||
this.on(k, l, ctx, opt); | ||
break; | ||
case OBJ: | ||
case NOBJ: | ||
case "object": | ||
case "nullobject": | ||
switch (n8iv.type(l[_fn])) { | ||
case FN: | ||
case OBJ: | ||
case NOBJ: | ||
case "function": | ||
case "object": | ||
case "nullobject": | ||
this.on(k, l[_fn], s, o); | ||
break; | ||
case ARR: | ||
case "array": | ||
l[_fn].forEach(function(fn) { | ||
@@ -1172,3 +1177,3 @@ this.on(k, fn, s, o); | ||
break; | ||
case ARR: | ||
case "array": | ||
l.forEach(function(fn) { | ||
@@ -1245,3 +1250,3 @@ this.on(k, fn, ctx, opt); | ||
switch (fnt = n8iv.nativeType(fn)) { | ||
case ARR: | ||
case "array": | ||
cb = n8iv.obj(); | ||
@@ -1254,4 +1259,4 @@ cb[event] = { | ||
return addObservers.call(this, cb); | ||
case OBJ: | ||
case NOBJ: | ||
case "object": | ||
case "nullobject": | ||
case "n8iv_callback": | ||
@@ -1281,4 +1286,4 @@ if ("handleEvent" in fn) { | ||
break; | ||
case OBJ: | ||
case NOBJ: | ||
case "object": | ||
case "nullobject": | ||
o = Object.clone(o); | ||
@@ -1319,5 +1324,5 @@ break; | ||
broadcast : function(event) { | ||
if (this[_destroyed] || this[_suspended] || !this[_observers][LEN] || !event || !this[_observers].has(event = event.lc())) return; | ||
var args = Array.from(arguments, 1), e = this[_observers].get(event).clone(); | ||
if (!e[LEN]) return; | ||
if (this[_destroyed] || this[_suspended] || !this[_observers].length || !event || !this[_observers].has(event = event.lc())) return; | ||
var args = Array.from(arguments, 1), e = this[_observers].get(event).slice(); | ||
if (!e.length) return; | ||
this[_broadcasting] = event; | ||
@@ -1324,0 +1329,0 @@ e.every(broadcast, { |
121
n8iv.Oo.js
!function(n8iv) { | ||
var F = !1, N = null, T = !0, U, cw = "cw", r = "r", ARR = "array", CTOR = "constructor", FN = "function", LEN = "length", OBJ = "object", NOBJ = N + OBJ, PROTO = "prototype", TYPE = "__type__"; | ||
var F = !1, N = null, T = !0, U; | ||
!function() { | ||
@@ -11,3 +11,3 @@ function Class(path, desc) { | ||
!n8iv.isStr(_super) || (_super = reg_path[_super] || reg_type[_super]); | ||
_ctor = desc[CTOR] !== Object ? desc[CTOR] : _super; | ||
_ctor = desc.constructor !== Object ? desc.constructor : _super; | ||
if (path) { | ||
@@ -18,10 +18,10 @@ ns = path.split("."); | ||
} | ||
n8iv.def(_proto, PARENT, n8iv.describe(n8iv.noop, cw), T); | ||
n8iv.def(_proto, CTOR, n8iv.describe(ctor(_ctor, _super[PROTO][CTOR], name, _proto), r), T); | ||
C = _proto[CTOR]; | ||
n8iv.def(C, TYPE, n8iv.describe("class", r), T); | ||
n8iv.def(_proto, TYPE, n8iv.describe(type, r), T); | ||
n8iv.def(_proto, "parent", n8iv.describe(n8iv.noop, "cw"), T); | ||
n8iv.def(_proto, "constructor", n8iv.describe(ctor(_ctor, _super.prototype.constructor, name, _proto), "r"), T); | ||
C = _proto.constructor; | ||
n8iv.def(C, "__type__", n8iv.describe("class", "r"), T); | ||
n8iv.def(_proto, "__type__", n8iv.describe(type, "r"), T); | ||
Object.remove(desc, defaults); | ||
C[PROTO] = apply(_proto, n8iv.copy(desc, mixin)); | ||
n8iv.def(C, "create", n8iv.describe(create(extend(C, _super)), r), T); | ||
C.prototype = apply(_proto, n8iv.copy(desc, mixin)); | ||
n8iv.def(C, "create", n8iv.describe(create(extend(C, _super)), "r"), T); | ||
path = path.replace(re_root, ""); | ||
@@ -31,3 +31,3 @@ if (singleton) { | ||
value : singleton === T ? new C : C.create.apply(C, [].concat(singleton)) | ||
}, r)); | ||
}, "r")); | ||
register(C, path, type); | ||
@@ -38,3 +38,3 @@ C = C.singleton; | ||
value : C | ||
}, r)); | ||
}, "r")); | ||
return C; | ||
@@ -45,3 +45,3 @@ } | ||
switch (n8iv.type(v)) { | ||
case OBJ: | ||
case "object": | ||
n8iv.def(proto, k, v, T); | ||
@@ -57,3 +57,3 @@ break; | ||
return function create() { | ||
return singleton(C) || C.apply(Object.create(C[PROTO]), arguments); | ||
return singleton(C) || C.apply(Object.create(C.prototype), arguments); | ||
}; | ||
@@ -68,8 +68,8 @@ } | ||
function extend(C, Sup) { | ||
if (!(SUPER in C[PROTO])) { | ||
var p = C[PROTO], sp = Sup[PROTO]; | ||
if (!("__super" in C.prototype)) { | ||
var p = C.prototype, sp = Sup.prototype; | ||
Object.keys(sp).forEach(function(k) { | ||
if (k in reserved) return; | ||
switch (n8iv.type(sp[k])) { | ||
case FN: | ||
case "function": | ||
p[k] = !n8iv.isFn(p[k]) ? wrap(sp[k], n8iv.noop, k) : wrap(p[k], sp[k], k); | ||
@@ -85,6 +85,6 @@ break; | ||
sp = n8iv.describe({ | ||
value : Object.create(Sup[PROTO]) | ||
}, r); | ||
n8iv.def(C, SUPER, sp); | ||
n8iv.def(C[PROTO], SUPER, sp); | ||
value : Object.create(Sup.prototype) | ||
}, "r"); | ||
n8iv.def(C, "__super", sp); | ||
n8iv.def(C.prototype, "__super", sp); | ||
} | ||
@@ -98,6 +98,6 @@ return C; | ||
if (o instanceof C) return T; | ||
if (!(o = o[CTOR])) return F; | ||
if (!(o = o.constructor)) return F; | ||
do { | ||
if (o === C) return T; | ||
} while (o[SUPER] && (o = o[SUPER][CTOR])); | ||
} while (o.__super && (o = o.__super.constructor)); | ||
return F; | ||
@@ -109,3 +109,3 @@ } | ||
!type || !(type in reg_type) || msg.push(err_msg + "Type"); | ||
if (msg[LEN]) { | ||
if (msg.length) { | ||
n8iv.trace(); | ||
@@ -121,3 +121,3 @@ msg.forEach(n8iv.error); | ||
function type(c) { | ||
var ctor = c[CTOR], k; | ||
var ctor = c.constructor, k; | ||
for (k in reg_path) if (reg_path[k] === ctor) return k; | ||
@@ -128,22 +128,22 @@ return N; | ||
return function() { | ||
var o, p = n8iv.description(this, PARENT) || desc_noop; | ||
var o, p = n8iv.description(this, "parent") || desc_noop; | ||
p.writable = T; | ||
n8iv.def(this, PARENT, s ? n8iv.describe(s, cw) : desc_noop, T); | ||
n8iv.def(this, "parent", s ? n8iv.describe(s, "cw") : desc_noop, T); | ||
o = m.apply(this, arguments); | ||
n8iv.def(this, PARENT, p, T); | ||
n8iv.def(this, "parent", p, T); | ||
return this.chain !== F && o === U ? this : o; | ||
}.mimic(m, name); | ||
} | ||
var ERR_MSG = " already exists. Cannot override existing ", PARENT = "parent", SUPER = "__super", defaults = (CTOR + " extend mixin module singleton type").split(" "), desc_noop = n8iv.describe(n8iv.noop, cw), dumb = n8iv.obj(), re_dot = /\./g, re_root = /^\u005E/, reg_path = n8iv.obj(), reg_type = n8iv.obj(), reserved = n8iv.obj(); | ||
reserved[CTOR] = reserved[PARENT] = reserved[SUPER] = reserved[TYPE] = T; | ||
n8iv.def(Class, "is", n8iv.describe(is, r)).def(Class, "type", n8iv.describe(type, r)).def(n8iv, "Class", n8iv.describe(Class, r)).def(n8iv, "create", n8iv.describe(function(n) { | ||
var ERR_MSG = " already exists. Cannot override existing ", defaults = "constructor extend mixin module singleton type".split(" "), desc_noop = n8iv.describe(n8iv.noop, "cw"), dumb = n8iv.obj(), re_dot = /\./g, re_root = /^\u005E/, reg_path = n8iv.obj(), reg_type = n8iv.obj(), reserved = n8iv.obj(); | ||
reserved.constructor = reserved.parent = reserved.__super = reserved.__type__ = T; | ||
n8iv.def(Class, "is", n8iv.describe(is, "r")).def(Class, "type", n8iv.describe(type, "r")).def(n8iv, "Class", n8iv.describe(Class, "r")).def(n8iv, "create", n8iv.describe(function(n) { | ||
var C = reg_type[n] || reg_type["n8iv_" + n] || reg_path[n], args = Array.from(arguments, 1); | ||
C || n8iv.trace().error(new Error(n + " does not match any registered n8iv.Classes."), T); | ||
return C.create.apply(n8iv.global, args); | ||
}, r)); | ||
}, "r")); | ||
}(); | ||
n8iv.Class("n8iv.Callback", function() { | ||
n8iv.def(Function[PROTO], "callback", n8iv.describe(function(conf) { | ||
n8iv.def(Function.prototype, "callback", n8iv.describe(function(conf) { | ||
return (new n8iv.Callback(this, conf)).fire.mimic(this); | ||
}, r)); | ||
}, "r")); | ||
function buffer() { | ||
@@ -161,7 +161,7 @@ if (bid in this) return this; | ||
} | ||
var bid = "bufferId", he = "handleEvent"; | ||
var bid = "bufferId", he = "handleEvent", tid = "timeoutId"; | ||
return { | ||
constructor : function Callback(fn, conf) { | ||
n8iv.copy(this, conf || n8iv.obj()); | ||
var desc = n8iv.describe(N, r), fire = (n8iv.isNum(this.buffer) ? buffer : this.exec).bind(this); | ||
var desc = n8iv.describe(N, "r"), fire = (n8iv.isNum(this.buffer) ? buffer : this.exec).bind(this); | ||
desc.value = fn; | ||
@@ -195,5 +195,7 @@ n8iv.def(this, "fn", desc); | ||
this.times === 0 || this.times > ++this.count || this.disable(); | ||
var a = Array.from(arguments), ctx = this.ctx, ms = this.delay, t = n8iv.type(a[0]), v; | ||
t && (t.endsWith("event") || t == "n8iv_observer") ? a.splice.apply(a, [ 1, 0 ].concat(this.args)) : a.unshift.apply(a, this.args); | ||
ms === N ? v = this.fn.apply(ctx, a) : this.fn.delay.apply(this.fn, [ ms, ctx ].concat(a)); | ||
var a = Array.from(arguments), me = this, ctx = me.ctx, ms = me.delay, t = n8iv.type(a[0]), v; | ||
t && (t.endsWith("event") || t == "n8iv_observer") ? a.splice.apply(a, [ 1, 0 ].concat(me.args)) : a.unshift.apply(a, me.args); | ||
ms === N ? v = me.fn.apply(ctx, a) : this[tid] = setTimeout(function() { | ||
me.fn.apply(ctx, a); | ||
}, ms); | ||
return v; | ||
@@ -204,2 +206,5 @@ }, | ||
buffer_stop.call(this.enable()); | ||
}, | ||
stop : function() { | ||
!(tid in this) || clearTimeout(this[tid]), delete this[tid]; | ||
} | ||
@@ -212,3 +217,3 @@ }; | ||
constructor : function Hash(o) { | ||
n8iv.def(this, ID, n8iv.describe(cache.push(n8iv.obj()) - 1, r)); | ||
n8iv.def(this, ID, n8iv.describe(cache.push(n8iv.obj()) - 1, "r")); | ||
!n8iv.isObj(o) || this.set(o); | ||
@@ -223,3 +228,3 @@ }, | ||
get : function() { | ||
return this.keys[LEN]; | ||
return this.keys.length; | ||
} | ||
@@ -273,4 +278,4 @@ }, | ||
switch (n8iv.type(o)) { | ||
case OBJ: | ||
case NOBJ: | ||
case "object": | ||
case "nullobject": | ||
Object.keys(o).forEach(function(k) { | ||
@@ -305,14 +310,14 @@ this.set(k, o[k]); | ||
switch (n8iv.type(l)) { | ||
case FN: | ||
case "function": | ||
this.on(k, l, ctx, opt); | ||
break; | ||
case OBJ: | ||
case NOBJ: | ||
case "object": | ||
case "nullobject": | ||
switch (n8iv.type(l[_fn])) { | ||
case FN: | ||
case OBJ: | ||
case NOBJ: | ||
case "function": | ||
case "object": | ||
case "nullobject": | ||
this.on(k, l[_fn], s, o); | ||
break; | ||
case ARR: | ||
case "array": | ||
l[_fn].forEach(function(fn) { | ||
@@ -324,3 +329,3 @@ this.on(k, fn, s, o); | ||
break; | ||
case ARR: | ||
case "array": | ||
l.forEach(function(fn) { | ||
@@ -397,3 +402,3 @@ this.on(k, fn, ctx, opt); | ||
switch (fnt = n8iv.nativeType(fn)) { | ||
case ARR: | ||
case "array": | ||
cb = n8iv.obj(); | ||
@@ -406,4 +411,4 @@ cb[event] = { | ||
return addObservers.call(this, cb); | ||
case OBJ: | ||
case NOBJ: | ||
case "object": | ||
case "nullobject": | ||
case "n8iv_callback": | ||
@@ -433,4 +438,4 @@ if ("handleEvent" in fn) { | ||
break; | ||
case OBJ: | ||
case NOBJ: | ||
case "object": | ||
case "nullobject": | ||
o = Object.clone(o); | ||
@@ -471,5 +476,5 @@ break; | ||
broadcast : function(event) { | ||
if (this[_destroyed] || this[_suspended] || !this[_observers][LEN] || !event || !this[_observers].has(event = event.lc())) return; | ||
var args = Array.from(arguments, 1), e = this[_observers].get(event).clone(); | ||
if (!e[LEN]) return; | ||
if (this[_destroyed] || this[_suspended] || !this[_observers].length || !event || !this[_observers].has(event = event.lc())) return; | ||
var args = Array.from(arguments, 1), e = this[_observers].get(event).slice(); | ||
if (!e.length) return; | ||
this[_broadcasting] = event; | ||
@@ -476,0 +481,0 @@ e.every(broadcast, { |
@@ -24,3 +24,3 @@ { | ||
}, | ||
"version" : "0.0.8" | ||
"version" : "0.1.0" | ||
} |
@@ -29,10 +29,10 @@ # n8iv.js | ||
<tbody> | ||
<tr><td style="width : 80px ;">n8iv._.js</td><td style="width : 48px ;">3.5kb</td><td>deflate</td> | ||
<tr><td style="width : 80px ;">n8iv._.js</td><td style="width : 48px ;">3.4kb</td><td>deflate</td> | ||
<tr><td>n8iv._.min.js</td><td>2.6kb</td><td>uglified + deflate</td> | ||
<tr><td>n8iv.Fn.js</td><td>4.0kb</td><td>deflate</td> | ||
<tr><td>n8iv.Fn.min.js</td><td>3.1kb</td><td>uglified + deflate</td> | ||
<tr><td>n8iv.Oo.js</td><td>4.5kb</td><td>deflate</td> | ||
<tr><td>n8iv.Oo.min.js</td><td>3.4kb</td><td>uglified + deflate</td> | ||
<tr><td>n8iv.js</td><td>11.1kb</td><td>deflate</td> | ||
<tr><td>n8iv.min.js</td><td>8.2kb</td><td>uglified + deflate</td> | ||
<tr><td>n8iv.Oo.js</td><td>4.4kb</td><td>deflate</td> | ||
<tr><td>n8iv.Oo.min.js</td><td>3.3kb</td><td>uglified + deflate</td> | ||
<tr><td>n8iv.js</td><td>10.9kb</td><td>deflate</td> | ||
<tr><td>n8iv.min.js</td><td>8.1kb</td><td>uglified + deflate</td> | ||
</tbody> | ||
@@ -39,0 +39,0 @@ </table> |
n8iv.ENV != 'commonjs' || module.exports === n8iv || ( module.exports = n8iv ); | ||
//}( this, typeof n8iv == 'undefined' ? this.document ? this.n8iv : require( './n8iv._' ) : n8iv ); | ||
}(); |
n8iv.ENV != 'commonjs' || module.exports === n8iv || ( module.exports = n8iv ); | ||
//}( this, typeof n8iv == 'undefined' ? this.document ? this.n8iv : require( './n8iv._' ) : n8iv ); | ||
}( typeof n8iv != 'undefined' ? n8iv : typeof require != 'undefined' ? require( './n8iv._' ) : N ); | ||
}( typeof n8iv != 'undefined' ? n8iv : typeof require != 'undefined' ? require( './n8iv._' ) : null ); |
196345
2654