Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[New] increase support from node 6 down to node 0.4
- Loading branch information
Showing
5 changed files
with
41 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"root": true, | ||
|
||
"extends": "@ljharb/eslint-config/node/6", | ||
"extends": "@ljharb", | ||
|
||
"overrides": [ | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,41 @@ | ||
'use strict'; | ||
|
||
const hasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key); | ||
const isObject = (val) => val !== null && typeof val === 'object' && !Array.isArray(val); | ||
var hasOwn = function (obj, key) { | ||
return Object.prototype.hasOwnProperty.call(obj, key); | ||
}; | ||
var isObject = function (val) { | ||
return val !== null && typeof val === 'object' && !Array.isArray(val); | ||
}; | ||
|
||
const isDescriptor = (obj, key) => { | ||
module.exports = function isDataDescriptor(obj, key) { | ||
if (!isObject(obj)) { | ||
return false; | ||
} | ||
const desc = key ? Object.getOwnPropertyDescriptor(obj, key) : obj; | ||
var desc = key ? Object.getOwnPropertyDescriptor(obj, key) : obj; | ||
if (isObject(desc)) { | ||
const booleans = [ | ||
'configurable', 'enumerable', 'writable', | ||
]; | ||
if (!hasOwn(desc, 'value') || hasOwn(desc, 'get') || hasOwn(desc, 'set')) { | ||
if ( | ||
!hasOwn(desc, 'value') | ||
|| hasOwn(desc, 'get') | ||
|| hasOwn(desc, 'set') | ||
|| (hasOwn(desc, 'configurable') && typeof desc.configurable !== 'boolean') | ||
|| (hasOwn(desc, 'enumerable') && typeof desc.enumerable !== 'boolean') | ||
|| (hasOwn(desc, 'writable') && typeof desc.writable !== 'boolean') | ||
) { | ||
return false; | ||
} | ||
for (const descKey of Object.keys(desc)) { | ||
if (booleans.includes(descKey) && typeof desc[descKey] !== 'boolean') { | ||
return false; | ||
} | ||
if (!booleans.includes(descKey) && descKey !== 'value') { | ||
for (var descKey in desc) { // eslint-disable-line no-restricted-syntax | ||
if ( | ||
hasOwn(desc, descKey) | ||
&& descKey !== 'configurable' | ||
&& descKey !== 'enumerable' | ||
&& descKey !== 'writable' | ||
&& descKey !== 'value' | ||
) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
return false; | ||
}; | ||
|
||
module.exports = isDescriptor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters