es-to-primitive
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -0,1 +1,12 @@ | ||
1.2.1 / 2019-11-08 | ||
================= | ||
* [readme] remove testling URLs | ||
* [meta] add `funding` field | ||
* [meta] create FUNDING.yml | ||
* [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `covert`, `replace`, `semver`, `tape`, `function.prototype.name` | ||
* [Tests] use shared travis-ci configs | ||
* [Tests] Add es5 tests for `symbol` types (#45) | ||
* [Tests] use `npx aud` instead of `nsp` or `npm audit` with hoops | ||
* [Tests] remove `jscs` | ||
1.2.0 / 2018-09-27 | ||
@@ -2,0 +13,0 @@ ================= |
@@ -0,3 +1,5 @@ | ||
'use strict'; | ||
module.exports = function isPrimitive(value) { | ||
return value === null || (typeof value !== 'function' && typeof value !== 'object'); | ||
}; |
{ | ||
"name": "es-to-primitive", | ||
"version": "1.2.0", | ||
"author": "Jordan Harband", | ||
"version": "1.2.1", | ||
"author": "Jordan Harband <ljharb@gmail.com>", | ||
"funding": { | ||
"url": "https://github.com/sponsors/ljharb" | ||
}, | ||
"description": "ECMAScript “ToPrimitive” algorithm. Provides ES5 and ES2015 versions.", | ||
@@ -11,10 +14,7 @@ "license": "MIT", | ||
"test": "npm run --silent tests-only", | ||
"posttest": "npm run --silent security", | ||
"posttest": "npx aud", | ||
"tests-only": "node --es-staging test", | ||
"coverage": "covert test/*.js", | ||
"coverage-quiet": "covert test/*.js --quiet", | ||
"lint": "npm run --silent jscs && npm run --silent eslint", | ||
"jscs": "jscs test/*.js *.js", | ||
"eslint": "eslint test/*.js *.js", | ||
"security": "nsp check" | ||
"lint": "eslint ." | ||
}, | ||
@@ -49,14 +49,13 @@ "repository": { | ||
"devDependencies": { | ||
"@ljharb/eslint-config": "^13.0.0", | ||
"covert": "^1.1.0", | ||
"eslint": "^5.6.0", | ||
"@ljharb/eslint-config": "^15.0.0", | ||
"covert": "^1.1.1", | ||
"eslint": "^6.6.0", | ||
"foreach": "^2.0.5", | ||
"function.prototype.name": "^1.1.0", | ||
"jscs": "^3.0.7", | ||
"nsp": "^3.2.1", | ||
"function.prototype.name": "^1.1.1", | ||
"has-symbols": "^1.0.0", | ||
"object-inspect": "^1.6.0", | ||
"object-is": "^1.0.1", | ||
"replace": "^1.0.0", | ||
"semver": "^5.5.1", | ||
"tape": "^4.9.1" | ||
"replace": "^1.1.1", | ||
"semver": "^6.3.0", | ||
"tape": "^4.11.0" | ||
}, | ||
@@ -63,0 +62,0 @@ "testling": { |
@@ -45,4 +45,2 @@ # es-to-primitive <sup>[![Version Badge][npm-version-svg]][package-url]</sup> | ||
[dev-deps-url]: https://david-dm.org/ljharb/es-to-primitive#info=devDependencies | ||
[testling-svg]: https://ci.testling.com/ljharb/es-to-primitive.png | ||
[testling-url]: https://ci.testling.com/ljharb/es-to-primitive | ||
[npm-badge-png]: https://nodei.co/npm/es-to-primitive.png?downloads=true&stars=true | ||
@@ -49,0 +47,0 @@ [license-image]: http://img.shields.io/npm/l/es-to-primitive.svg |
@@ -9,2 +9,3 @@ 'use strict'; | ||
var debug = require('object-inspect'); | ||
var hasSymbols = require('has-symbols')(); | ||
@@ -29,2 +30,25 @@ test('function properties', function (t) { | ||
test('Symbols', { skip: !hasSymbols }, function (t) { | ||
var symbols = [ | ||
Symbol('foo'), | ||
Symbol.iterator, | ||
Symbol['for']('foo') // eslint-disable-line no-restricted-properties | ||
]; | ||
forEach(symbols, function (sym) { | ||
t.equal(toPrimitive(sym), sym, 'toPrimitive(' + debug(sym) + ') returns the same value'); | ||
t.equal(toPrimitive(sym, String), sym, 'toPrimitive(' + debug(sym) + ', String) returns the same value'); | ||
t.equal(toPrimitive(sym, Number), sym, 'toPrimitive(' + debug(sym) + ', Number) returns the same value'); | ||
}); | ||
var primitiveSym = Symbol('primitiveSym'); | ||
var stringSym = Symbol.prototype.toString.call(primitiveSym); | ||
var objectSym = Object(primitiveSym); | ||
t.equal(toPrimitive(objectSym), primitiveSym, 'toPrimitive(' + debug(objectSym) + ') returns ' + debug(primitiveSym)); | ||
// This is different from ES2015, as the ES5 algorithm doesn't account for the existence of Symbols: | ||
t.equal(toPrimitive(objectSym, String), stringSym, 'toPrimitive(' + debug(objectSym) + ', String) returns ' + debug(stringSym)); | ||
t.equal(toPrimitive(objectSym, Number), primitiveSym, 'toPrimitive(' + debug(objectSym) + ', Number) returns ' + debug(primitiveSym)); | ||
t.end(); | ||
}); | ||
test('Arrays', function (t) { | ||
@@ -31,0 +55,0 @@ var arrays = [[], ['a', 'b'], [1, 2]]; |
@@ -10,3 +10,3 @@ 'use strict'; | ||
var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol'; | ||
var hasSymbols = require('has-symbols')(); | ||
var hasSymbolToPrimitive = hasSymbols && typeof Symbol.toPrimitive === 'symbol'; | ||
@@ -13,0 +13,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11
40434
17
493
50