Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
added m8.ntype alias for m8.nativeType
Browse files Browse the repository at this point in the history
added m8.description as shorthand for Object.getOwnPropertyDescriptor
  • Loading branch information
constantology committed Nov 1, 2012
1 parent 0556d57 commit a9c999b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 25 deletions.
21 changes: 12 additions & 9 deletions m8.js
Expand Up @@ -98,7 +98,7 @@
case 'object' : mode = args.shift(); break;
default :
ntype = nativeType( desc );
mode = ntype != 'object' && defined ? Object.getOwnPropertyDescriptor( item, name ) : null;
mode = ntype != 'object' && defined ? description( item, name ) : null;
!mode || ( mode = ntype == 'function' ? modes.cw : modes.cew );
}
overwrite = args.shift() === true;
Expand All @@ -125,6 +125,9 @@
function describe( desc, mode ) {
return copy( ( nativeType( desc ) == 'object' ? desc : { value : desc } ), ( nativeType( mode ) == 'object' ? mode : modes[String( mode ).toLowerCase()] || modes.cew ), true );
}
function description( item, property ) {
return Object.getOwnPropertyDescriptor( item, property );
}

function empty( item ) { return !exists( item ) || ( !len( item ) && iter( item ) ) || false; }
function exists( item ) { return !( item === null || item === UNDEF || ( typeof item == 'number' && isNaN( item ) ) ); }
Expand Down Expand Up @@ -233,7 +236,7 @@

if ( test( item, property ) )
return true;

if ( typeof item != 'string' && !!~property.indexOf( '.' ) ) {
property = property.split( '.' );

Expand Down Expand Up @@ -465,14 +468,14 @@

defs( ( __lib__ = expose( __lib__, Name, PACKAGE ) ), {
// properties
ENV : ENV, global : { value : root }, modes : { value : modes },
ENV : ENV, global : { value : root }, modes : { value : modes },
// methods
bless : bless, coerce : coerce, copy : copy, def : def, defs : defs,
describe : describe, empty : empty, exists : exists, expose : expose,
got : property_exists.bind( null, got ), guid : guid, has : property_exists.bind( null, has ),
id : id, iter : iter, len : len, merge : merge, nativeType : nativeType,
noop : noop, obj : obj, range : range, remove : remove, tostr : tostr,
type : type, update : update, valof : valof, x : x
bless : bless, coerce : coerce, copy : copy, def : def, defs : defs,
describe : describe, description : description, empty : empty, exists : exists, expose : expose,
got : property_exists.bind( null, got ), guid : guid, has : property_exists.bind( null, has ),
id : id, iter : iter, len : len, merge : merge, nativeType : nativeType,
noop : noop, ntype : nativeType, obj : obj, range : range, remove : remove,
tostr : tostr, type : type, update : update, valof : valof, x : x
}, 'w' );

x( Object, Array, Boolean, Function );
Expand Down
2 changes: 1 addition & 1 deletion m8.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions src/expose.js
Expand Up @@ -2,14 +2,14 @@

defs( ( __lib__ = expose( __lib__, Name, PACKAGE ) ), {
// properties
ENV : ENV, global : { value : root }, modes : { value : modes },
ENV : ENV, global : { value : root }, modes : { value : modes },
// methods
bless : bless, coerce : coerce, copy : copy, def : def, defs : defs,
describe : describe, empty : empty, exists : exists, expose : expose,
got : property_exists.bind( null, got ), guid : guid, has : property_exists.bind( null, has ),
id : id, iter : iter, len : len, merge : merge, nativeType : nativeType,
noop : noop, obj : obj, range : range, remove : remove, tostr : tostr,
type : type, update : update, valof : valof, x : x
bless : bless, coerce : coerce, copy : copy, def : def, defs : defs,
describe : describe, description : description, empty : empty, exists : exists, expose : expose,
got : property_exists.bind( null, got ), guid : guid, has : property_exists.bind( null, has ),
id : id, iter : iter, len : len, merge : merge, nativeType : nativeType,
noop : noop, ntype : nativeType, obj : obj, range : range, remove : remove,
tostr : tostr, type : type, update : update, valof : valof, x : x
}, 'w' );

x( Object, Array, Boolean, Function );

0 comments on commit a9c999b

Please sign in to comment.