object keys
1.0.0
一个 Object.keys 垫片。如果不可用,则调用其“shim”方法来填充 Object.keys。
最常见的用法:
var keys = Object . keys || require ( 'object-keys' ) ;
var keys = require ( 'object-keys' ) ;
var assert = require ( 'assert' ) ;
var obj = {
a : true ,
b : true ,
c : true
} ;
assert . deepEqual ( keys ( obj ) , [ 'a' , 'b' , 'c' ] ) ;
var keys = require ( 'object-keys' ) ;
var assert = require ( 'assert' ) ;
/* when Object.keys is not present */
delete Object . keys ;
var shimmedKeys = keys . shim ( ) ;
assert . equal ( shimmedKeys , keys ) ;
assert . deepEqual ( Object . keys ( obj ) , keys ( obj ) ) ;
var keys = require ( 'object-keys' ) ;
var assert = require ( 'assert' ) ;
/* when Object.keys is present */
var shimmedKeys = keys . shim ( ) ;
assert . equal ( shimmedKeys , Object . keys ) ;
assert . deepEqual ( Object . keys ( obj ) , keys ( obj ) ) ;
直接取自 es5-shim 的实现,并进行了修改,包括来自 lodash 的修改。
只需克隆存储库、 npm install
并运行npm test