mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
Simplify Object.defineProperty use.
This commit is contained in:
13
test/test.js
13
test/test.js
@@ -44,6 +44,7 @@
|
|||||||
amd = root.define && define.amd,
|
amd = root.define && define.amd,
|
||||||
argv = root.process && process.argv,
|
argv = root.process && process.argv,
|
||||||
ArrayBuffer = root.ArrayBuffer,
|
ArrayBuffer = root.ArrayBuffer,
|
||||||
|
defineProperty = Object.defineProperty,
|
||||||
document = !phantom && root.document,
|
document = !phantom && root.document,
|
||||||
body = root.document && root.document.body,
|
body = root.document && root.document.body,
|
||||||
create = Object.create,
|
create = Object.create,
|
||||||
@@ -69,16 +70,6 @@
|
|||||||
isEven = function(n) { return n % 2 == 0; },
|
isEven = function(n) { return n % 2 == 0; },
|
||||||
square = function(n) { return n * n; };
|
square = function(n) { return n * n; };
|
||||||
|
|
||||||
/** Used to set property descriptors. */
|
|
||||||
var defineProperty = (function() {
|
|
||||||
try {
|
|
||||||
var o = {},
|
|
||||||
func = Object.defineProperty,
|
|
||||||
result = func(o, o, o) && func;
|
|
||||||
} catch (e) {}
|
|
||||||
return result;
|
|
||||||
}());
|
|
||||||
|
|
||||||
/** The file path of the lodash file to test. */
|
/** The file path of the lodash file to test. */
|
||||||
var filePath = (function() {
|
var filePath = (function() {
|
||||||
var min = 2,
|
var min = 2,
|
||||||
@@ -183,7 +174,7 @@
|
|||||||
|
|
||||||
/** Poison the free variable `root` in Node.js */
|
/** Poison the free variable `root` in Node.js */
|
||||||
try {
|
try {
|
||||||
Object.defineProperty(global.root, 'root', {
|
defineProperty(global.root, 'root', {
|
||||||
'configurable': false,
|
'configurable': false,
|
||||||
'enumerable': false,
|
'enumerable': false,
|
||||||
'get': function() { throw new ReferenceError; }
|
'get': function() { throw new ReferenceError; }
|
||||||
|
|||||||
Reference in New Issue
Block a user