Comparing version 0.1.3 to 0.1.4
42
m8.js
@@ -105,5 +105,40 @@ !function(root, Name) { | ||
} | ||
function obj(o, n) { | ||
return (n = Object.create(null)) && arguments.length >= 1 ? copy(n, o) : n; | ||
function merge(a, b) { | ||
var type; | ||
if (!b) { | ||
switch (type = nativeType(a)) { | ||
case "array": | ||
case "object": | ||
b = a; | ||
a = new (b.constructor || Object); | ||
break; | ||
default: | ||
return a; | ||
} | ||
} else type = nativeType(b); | ||
switch (type) { | ||
case "object": | ||
return Object.keys(b).reduce(merge_object, { | ||
source : b, | ||
target : a | ||
}).target; | ||
case "array": | ||
a.length = b.length; | ||
return b.reduce(merge_array, a); | ||
default: | ||
return b; | ||
} | ||
} | ||
function merge_array(a, v, i) { | ||
a[i] = merge(v); | ||
return a; | ||
} | ||
function merge_object(o, k) { | ||
o.target[k] = merge(o.source[k]); | ||
return o; | ||
} | ||
function obj(o) { | ||
var n = Object.create(null); | ||
return o && nativeType(o) == "object" ? copy(n, o) : n; | ||
} | ||
function tostr(o) { | ||
@@ -179,2 +214,3 @@ return OP.toString.call(o); | ||
len : len, | ||
merge : merge, | ||
nativeType : nativeType, | ||
@@ -247,3 +283,3 @@ noop : function() {}, | ||
if (!this.__xname__) { | ||
var fn = valof(this), m = fn !== this ? fn.__name__ !== "anonymous" ? fn.__name__ : null : null, n = m || fname(this); | ||
var fn = this.valueOf(), m = fn !== this ? fn.__name__ !== "anonymous" ? fn.__name__ : null : null, n = m || fname(this); | ||
def(this, "__xname__", describe(m || n || "anonymous", "w")); | ||
@@ -250,0 +286,0 @@ } |
@@ -20,3 +20,3 @@ { | ||
}, | ||
"version" : "0.1.3" | ||
"version" : "0.1.4" | ||
} |
@@ -410,2 +410,5 @@ # m8.js | ||
### m8.iter( item:Mixed ):Boolean | ||
Returns `true` if the passed item can be iterated over. | ||
### m8.len( item:Mixed ):Number | ||
@@ -429,2 +432,5 @@ Tries the returns the `length` property of the passed `item`. | ||
### m8.merge( destination:Array|Object, source:Array|Object ):Boolean | ||
Performs a "deep copy" of all the properties in `source` to `target`, so that `target` does not reference any child Arrays and/ or Objects that belong to `source`. | ||
### m8.nativeType( item:Mixed ):String | ||
@@ -759,4 +765,4 @@ Returns the native `type` of the passed item. For normalised types use `m8.type`. | ||
<tbody> | ||
<tr><td style="width : 80px ;">m8.js</td><td style="width : 48px ;">3.27kb</td><td>deflate</td> | ||
<tr><td>m8.min.js</td><td>2.47kb</td><td>uglified + deflate</td> | ||
<tr><td style="width : 80px ;">m8.js</td><td style="width : 48px ;">3.73kb</td><td>deflate</td> | ||
<tr><td>m8.min.js</td><td>2.86kb</td><td>uglified + deflate</td> | ||
</tbody> | ||
@@ -763,0 +769,0 @@ </table> |
43599
337
779