Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

es-abstract

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es-abstract - npm Package Compare versions

Comparing version 1.5.1 to 1.6.0

7

CHANGELOG.md

@@ -0,1 +1,8 @@

1.6.0 / 2016-08-20
=================
* [New] ES5 / ES6: add `Type`
* [New] ES6: `SpeciesConstructor`
* [Dev Deps] update `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config`, `semver`; add `safe-publish-latest`
* [Tests] up to `node` `v6.4`, `v5.12`, `v4.5`
1.5.1 / 2016-05-30

@@ -2,0 +9,0 @@ =================

@@ -61,2 +61,24 @@ 'use strict';

return $isNaN(x) && $isNaN(y);
},
// http://www.ecma-international.org/ecma-262/5.1/#sec-8
Type: function Type(x) {
if (x === null) {
return 'Null';
}
if (typeof x === 'undefined') {
return 'Undefined';
}
if (typeof x === 'function' || typeof x === 'object') {
return 'Object';
}
if (typeof x === 'number') {
return 'Number';
}
if (typeof x === 'boolean') {
return 'Boolean';
}
if (typeof x === 'string') {
return 'String';
}
}

@@ -63,0 +85,0 @@ };

@@ -227,2 +227,31 @@ 'use strict';

return (x === y) || ($isNaN(x) && $isNaN(y));
},
Type: function Type(x) {
if (typeof x === 'symbol') {
return 'Symbol';
}
return ES5.Type(x);
},
// http://www.ecma-international.org/ecma-262/6.0/#sec-speciesconstructor
SpeciesConstructor: function SpeciesConstructor(O, defaultConstructor) {
if (this.Type(O) !== 'Object') {
throw new TypeError('Assertion failed: Type(O) is not Object');
}
var C = O.constructor;
if (typeof C === 'undefined') {
return defaultConstructor;
}
if (this.Type(C) !== 'Object') {
throw new TypeError('O.constructor is not an Object');
}
var S = hasSymbols && Symbol.species ? C[Symbol.species] : undefined;
if (S == null) {
return defaultConstructor;
}
if (this.IsConstructor(S)) {
return S;
}
throw new TypeError('no constructor found');
}

@@ -229,0 +258,0 @@ });

18

package.json
{
"name": "es-abstract",
"version": "1.5.1",
"version": "1.6.0",
"author": {

@@ -20,2 +20,3 @@ "name": "Jordan Harband",

"scripts": {
"prepublish": "safe-publish-latest",
"pretest": "npm run --silent lint",

@@ -55,13 +56,14 @@ "test": "npm run tests-only",

"devDependencies": {
"tape": "^4.5.1",
"tape": "^4.6.0",
"covert": "^1.1.0",
"jscs": "^3.0.3",
"jscs": "^3.0.7",
"editorconfig-tools": "^0.1.1",
"nsp": "^2.4.0",
"eslint": "^2.11.1",
"@ljharb/eslint-config": "^5.0.0",
"nsp": "^2.6.1",
"eslint": "^3.3.1",
"@ljharb/eslint-config": "^7.0.0",
"object-is": "^1.0.1",
"foreach": "^2.0.5",
"semver": "^5.1.0",
"replace": "^0.3.0"
"semver": "^5.3.0",
"replace": "^0.3.0",
"safe-publish-latest": "^1.0.1"
},

@@ -68,0 +70,0 @@ "testling": {

@@ -193,1 +193,15 @@ 'use strict';

});
test('Type', function (t) {
t.equal(ES.Type(), 'Undefined', 'Type() is Undefined');
t.equal(ES.Type(undefined), 'Undefined', 'Type(undefined) is Undefined');
t.equal(ES.Type(null), 'Null', 'Type(null) is Null');
t.equal(ES.Type(true), 'Boolean', 'Type(true) is Boolean');
t.equal(ES.Type(false), 'Boolean', 'Type(false) is Boolean');
t.equal(ES.Type(0), 'Number', 'Type(0) is Number');
t.equal(ES.Type(NaN), 'Number', 'Type(NaN) is Number');
t.equal(ES.Type('abc'), 'String', 'Type("abc") is String');
t.equal(ES.Type(function () {}), 'Object', 'Type(function () {}) is Object');
t.equal(ES.Type({}), 'Object', 'Type({}) is Object');
t.end();
});

@@ -482,1 +482,57 @@ 'use strict';

});
test('Type', { skip: !hasSymbols }, function (t) {
t.equal(ES.Type(Symbol.iterator), 'Symbol', 'Type(Symbol.iterator) is Symbol');
t.end();
});
test('SpeciesConstructor', function (t) {
t.throws(function () { ES.SpeciesConstructor(null); }, TypeError);
t.throws(function () { ES.SpeciesConstructor(undefined); }, TypeError);
var defaultConstructor = function Foo() {};
t.equal(
ES.SpeciesConstructor({ constructor: undefined }, defaultConstructor),
defaultConstructor,
'undefined constructor returns defaultConstructor'
);
t.throws(
function () { return ES.SpeciesConstructor({ constructor: null }, defaultConstructor); },
TypeError,
'non-undefined non-object constructor throws'
);
var Bar = function Bar() {};
var hasSpecies = hasSymbols && Symbol.species;
if (hasSpecies) {
Bar[Symbol.species] = null;
}
t.equal(
ES.SpeciesConstructor(new Bar(), defaultConstructor),
defaultConstructor,
'undefined/null Symbol.species returns default constructor'
);
t.test('with Symbol.species', { skip: !hasSpecies }, function (st) {
var Baz = function Baz() {};
Baz[Symbol.species] = Bar;
st.equal(
ES.SpeciesConstructor(new Baz(), defaultConstructor),
Bar,
'returns Symbol.species constructor value'
);
Baz[Symbol.species] = {};
st.throws(
function () { ES.SpeciesConstructor(new Baz(), defaultConstructor); },
TypeError,
'throws when non-constructor non-null non-undefined species value found'
);
st.end();
});
t.end();
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc