Socket
Socket
Sign inDemoInstall

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.9.0 to 1.10.0

7

CHANGELOG.md

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

1.9.0 / 2017-11-24
=================
* [New] ES2015+: `AdvanceStringIndex`
* [Dev Deps] update `eslint`, `nsp`
* [Tests] require node 0.6 to pass again
* [Tests] up to `node` `v9.2`, `v8.9`, `v6.12`; use `nvm install-latest-npm`; pin included builds to LTS
1.9.0 / 2017-09-30

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

@@ -528,2 +528,34 @@ 'use strict';

return success;
},
// http://ecma-international.org/ecma-262/6.0/#sec-advancestringindex
AdvanceStringIndex: function AdvanceStringIndex(S, index, unicode) {
if (this.Type(S) !== 'String') {
throw new TypeError('Assertion failed: Type(S) is not String');
}
if (!this.IsInteger(index)) {
throw new TypeError('Assertion failed: length must be an integer >= 0 and <= (2**53 - 1)');
}
if (index < 0 || index > MAX_SAFE_INTEGER) {
throw new RangeError('Assertion failed: length must be an integer >= 0 and <= (2**53 - 1)');
}
if (this.Type(unicode) !== 'Boolean') {
throw new TypeError('Assertion failed: Type(unicode) is not Boolean');
}
if (!unicode) {
return index + 1;
}
var length = S.length;
if ((index + 1) >= length) {
return index + 1;
}
var first = S.charCodeAt(index);
if (first < 0xD800 || first > 0xDBFF) {
return index + 1;
}
var second = S.charCodeAt(index + 1);
if (second < 0xDC00 || second > 0xDFFF) {
return index + 1;
}
return index + 2;
}

@@ -530,0 +562,0 @@ });

3

operations/2015.js

@@ -74,3 +74,4 @@ 'use strict';

IsPromise: 'http://ecma-international.org/ecma-262/6.0/#sec-ispromise',
ArraySpeciesCreate: 'http://ecma-international.org/ecma-262/6.0/#sec-arrayspeciescreate'
ArraySpeciesCreate: 'http://ecma-international.org/ecma-262/6.0/#sec-arrayspeciescreate',
AdvanceStringIndex: 'http://ecma-international.org/ecma-262/6.0/#sec-advancestringindex'
};

@@ -75,3 +75,4 @@ 'use strict';

IsPromise: 'http://ecma-international.org/ecma-262/7.0/#sec-ispromise',
ArraySpeciesCreate: 'http://ecma-international.org/ecma-262/7.0/#sec-arrayspeciescreate'
ArraySpeciesCreate: 'http://ecma-international.org/ecma-262/7.0/#sec-arrayspeciescreate',
AdvanceStringIndex: 'http://ecma-international.org/ecma-262/6.0/#sec-advancestringindex'
};

@@ -76,3 +76,4 @@ 'use strict';

IsPromise: 'http://ecma-international.org/ecma-262/8.0/#sec-ispromise',
ArraySpeciesCreate: 'http://ecma-international.org/ecma-262/8.0/#sec-arrayspeciescreate'
ArraySpeciesCreate: 'http://ecma-international.org/ecma-262/8.0/#sec-arrayspeciescreate',
AdvanceStringIndex: 'http://ecma-international.org/ecma-262/6.0/#sec-advancestringindex'
};
{
"name": "es-abstract",
"version": "1.9.0",
"version": "1.10.0",
"author": {

@@ -58,6 +58,6 @@ "name": "Jordan Harband",

"editorconfig-tools": "^0.1.1",
"eslint": "^4.8.0",
"eslint": "^4.11.0",
"foreach": "^2.0.5",
"jscs": "^3.0.7",
"nsp": "^2.8.1",
"nsp": "^3.1.0",
"nyc": "^10.3.2",

@@ -64,0 +64,0 @@ "object-is": "^1.0.1",

@@ -1420,2 +1420,86 @@ 'use strict';

});
test('AdvanceStringIndex', function (t) {
forEach(v.nonStrings, function (nonString) {
t['throws'](
function () { ES.AdvanceStringIndex(nonString); },
TypeError,
'"S" argument must be a String; ' + debug(nonString) + ' is not'
);
});
forEach(v.nonIntegerNumbers, function (nonInteger) {
t['throws'](
function () { ES.AdvanceStringIndex('', nonInteger, false); },
TypeError,
'"index" argument must be an integer; ' + debug(nonInteger) + ' is not'
);
});
forEach([-1, -42], function (negative) {
t['throws'](
function () { ES.AdvanceStringIndex('', negative, false); },
RangeError,
'"index" argument must be a non-negative integer; ' + debug(negative) + ' is not'
);
});
t['throws'](
function () { ES.AdvanceStringIndex('', MAX_SAFE_INTEGER + 1, false); },
RangeError,
'too large integers throw'
);
forEach(v.nonBooleans, function (nonBoolean) {
t['throws'](
function () { ES.AdvanceStringIndex('', 0, nonBoolean); },
TypeError,
'"unicode" argument must be a Boolean; ' + debug(nonBoolean) + ' is not'
);
});
t.test('when unicode is false', function (st) {
st.equal(ES.AdvanceStringIndex('', 0, false), 1, 'index is incremented by 1');
st.equal(ES.AdvanceStringIndex('abc', 0, false), 1, 'index is incremented by 1');
st.equal(ES.AdvanceStringIndex('', 3, false), 4, 'index is incremented by 1');
st.equal(ES.AdvanceStringIndex('abc', 3, false), 4, 'index is incremented by 1');
st.test('when the index is within the string', function (s2t) {
s2t.equal(ES.AdvanceStringIndex('abc', 0, false), 1, '0 -> 1');
s2t.equal(ES.AdvanceStringIndex('abc', 1, false), 2, '1 -> 2');
s2t.equal(ES.AdvanceStringIndex('abc', 2, false), 3, '2 -> 3');
s2t.end();
});
st.end();
});
t.test('when unicode is true', function (st) {
st.test('when index + 1 >= length', function (s2t) {
t.equal(ES.AdvanceStringIndex('', 0, true), 1, 'index is incremented by 1');
t.equal(ES.AdvanceStringIndex('a', 0, true), 1, 'index is incremented by 1');
t.equal(ES.AdvanceStringIndex('a', 5, true), 6, 'index is incremented by 1');
s2t.end();
});
st.test('when the index is within the string', function (s2t) {
s2t.equal(ES.AdvanceStringIndex('abc', 0, true), 1, '0 -> 1');
s2t.equal(ES.AdvanceStringIndex('abc', 1, true), 2, '1 -> 2');
s2t.equal(ES.AdvanceStringIndex('abc', 2, true), 3, '2 -> 3');
s2t.end();
});
st.test('surrogate pairs', function (s2t) {
var lowestPair = String.fromCharCode('0xD800') + String.fromCharCode('0xDC00');
var highestPair = String.fromCharCode('0xDBFF') + String.fromCharCode('0xDFFF');
var poop = String.fromCharCode('0xD83D') + String.fromCharCode('0xDCA9');
s2t.equal(ES.AdvanceStringIndex(lowestPair, 0, true), 2, 'lowest surrogate pair, 0 -> 2');
s2t.equal(ES.AdvanceStringIndex(highestPair, 0, true), 2, 'highest surrogate pair, 0 -> 2');
s2t.equal(ES.AdvanceStringIndex(poop, 0, true), 2, 'poop, 0 -> 2');
s2t.end();
});
st.end();
});
t.end();
});
};

@@ -1422,0 +1506,0 @@

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