string.prototype.replaceall
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -10,21 +10,33 @@ # Changelog | ||
## [v1.0.2](https://github.com/ljharb/String.prototype.replaceAll/compare/v1.0.1...v1.0.2) - 2019-10-31 | ||
## [v1.0.3](https://github.com/es-shims/String.prototype.replaceAll/compare/v1.0.2...v1.0.3) - 2019-12-14 | ||
### Commits | ||
- [Tests] use shared travis-ci configs [`3568ec6`](https://github.com/es-shims/String.prototype.replaceAll/commit/3568ec65bd75a5e1bb26385416c6152a0b46aa8a) | ||
- [meta] rerun `auto-changelog` [`d3d9c4b`](https://github.com/es-shims/String.prototype.replaceAll/commit/d3d9c4b49d6b4e570dac8ea994fa66feeef68501) | ||
- [Refactor] use split-up `es-abstract` (71% bundle size decrease) [`ea58502`](https://github.com/es-shims/String.prototype.replaceAll/commit/ea585029afa62b850ec937a4d4ef39472b4d52c1) | ||
- [actions] add automatic rebasing / merge commit blocking [`b560c40`](https://github.com/es-shims/String.prototype.replaceAll/commit/b560c408c1249cb0c5c56a0608a97cb4b0e9595c) | ||
- [Deps] update `es-abstract`, `has-symbols` [`8835acf`](https://github.com/es-shims/String.prototype.replaceAll/commit/8835acf51d5b39c3d7e815dc04e0da803b2838e9) | ||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config` [`9bf0752`](https://github.com/es-shims/String.prototype.replaceAll/commit/9bf07522a32a425bb955a8a26b71c1044402cbab) | ||
- [meta] add `funding` field [`b224153`](https://github.com/es-shims/String.prototype.replaceAll/commit/b224153fd7015edea8da28426d05690f20cf29db) | ||
## [v1.0.2](https://github.com/es-shims/String.prototype.replaceAll/compare/v1.0.1...v1.0.2) - 2019-10-31 | ||
### Fixed | ||
- [Deps] add missing `define-properties` [`#2`](https://github.com/ljharb/String.prototype.replaceAll/issues/2) | ||
- [Deps] add missing `define-properties` [`#2`](https://github.com/es-shims/String.prototype.replaceAll/issues/2) | ||
## [v1.0.1](https://github.com/ljharb/String.prototype.replaceAll/compare/v1.0.0...v1.0.1) - 2019-10-26 | ||
## [v1.0.1](https://github.com/es-shims/String.prototype.replaceAll/compare/v1.0.0...v1.0.1) - 2019-10-26 | ||
### Fixed | ||
- [Fix] handle an empty string searchValue [`#1`](https://github.com/ljharb/String.prototype.replaceAll/issues/1) | ||
- [Fix] handle an empty string searchValue [`#1`](https://github.com/es-shims/String.prototype.replaceAll/issues/1) | ||
### Commits | ||
- [Deps] update `es-abstract` [`2ab3464`](https://github.com/ljharb/String.prototype.replaceAll/commit/2ab346486859f0f1448f53547740df5274af00c5) | ||
- [Tests] up to `node` `v13.0`, `v12.13`, `v10.17` [`be6a236`](https://github.com/ljharb/String.prototype.replaceAll/commit/be6a2366fd8f57a87af8aaa98ef6b72d66852392) | ||
- [meta] use keepachangelog format [`f5248bb`](https://github.com/ljharb/String.prototype.replaceAll/commit/f5248bb1aea82b6d9c3ca9d250f1b45d540b3d0f) | ||
- [Dev Deps] update `eslint`, `functions-have-names`, `auto-changelog` [`5be4a77`](https://github.com/ljharb/String.prototype.replaceAll/commit/5be4a77a7cf593055f57b8a50147e5868f922f27) | ||
- [Dev Deps] update `eslint` [`376879f`](https://github.com/ljharb/String.prototype.replaceAll/commit/376879f87bd75b1939620bf866af35b15582ad5c) | ||
- [Deps] update `es-abstract` [`2ab3464`](https://github.com/es-shims/String.prototype.replaceAll/commit/2ab346486859f0f1448f53547740df5274af00c5) | ||
- [Tests] up to `node` `v13.0`, `v12.13`, `v10.17` [`be6a236`](https://github.com/es-shims/String.prototype.replaceAll/commit/be6a2366fd8f57a87af8aaa98ef6b72d66852392) | ||
- [meta] use keepachangelog format [`f5248bb`](https://github.com/es-shims/String.prototype.replaceAll/commit/f5248bb1aea82b6d9c3ca9d250f1b45d540b3d0f) | ||
- [Dev Deps] update `eslint`, `functions-have-names`, `auto-changelog` [`5be4a77`](https://github.com/es-shims/String.prototype.replaceAll/commit/5be4a77a7cf593055f57b8a50147e5868f922f27) | ||
- [Dev Deps] update `eslint` [`376879f`](https://github.com/es-shims/String.prototype.replaceAll/commit/376879f87bd75b1939620bf866af35b15582ad5c) | ||
@@ -35,11 +47,11 @@ ## v1.0.0 - 2019-09-04 | ||
- tests [`0d23a9b`](https://github.com/ljharb/String.prototype.replaceAll/commit/0d23a9b46f4c0d10f4fe41fcf644e729b73dccf8) | ||
- implementation [`d44c2e9`](https://github.com/ljharb/String.prototype.replaceAll/commit/d44c2e96b823997c669879a6f7de1ac894a35634) | ||
- Initial commit [`6dc47f9`](https://github.com/ljharb/String.prototype.replaceAll/commit/6dc47f9a516f4881b451129936c3275168cf5405) | ||
- readme [`08c5710`](https://github.com/ljharb/String.prototype.replaceAll/commit/08c571056a42d9820f403035796e74172e68ca3d) | ||
- npm init [`f666051`](https://github.com/ljharb/String.prototype.replaceAll/commit/f666051cb7d2d3392d2ba30dfad952048ff47d5b) | ||
- non-global regexes throw, pending web compatibility data [`fbd9a60`](https://github.com/ljharb/String.prototype.replaceAll/commit/fbd9a60c929575111721f9c71d5638804614ba21) | ||
- [fix] add fallback for pre-Symbol.replace engines [`57b33d3`](https://github.com/ljharb/String.prototype.replaceAll/commit/57b33d3dbb8348f2b9e83a652a1771c447e953e8) | ||
- [Tests] add `npm run lint` [`a979c0f`](https://github.com/ljharb/String.prototype.replaceAll/commit/a979c0fc27735abb3a710ae80be5c5c564a5d1fe) | ||
- [meta] add auto-changelog [`f780972`](https://github.com/ljharb/String.prototype.replaceAll/commit/f78097211dcc9a22f805f4198026ee87a41d14e1) | ||
- Only apps should have lockfiles [`b9dc48f`](https://github.com/ljharb/String.prototype.replaceAll/commit/b9dc48f43711a8d38515aeafdd0ffc6a985465bc) | ||
- tests [`0d23a9b`](https://github.com/es-shims/String.prototype.replaceAll/commit/0d23a9b46f4c0d10f4fe41fcf644e729b73dccf8) | ||
- implementation [`d44c2e9`](https://github.com/es-shims/String.prototype.replaceAll/commit/d44c2e96b823997c669879a6f7de1ac894a35634) | ||
- Initial commit [`6dc47f9`](https://github.com/es-shims/String.prototype.replaceAll/commit/6dc47f9a516f4881b451129936c3275168cf5405) | ||
- readme [`08c5710`](https://github.com/es-shims/String.prototype.replaceAll/commit/08c571056a42d9820f403035796e74172e68ca3d) | ||
- npm init [`f666051`](https://github.com/es-shims/String.prototype.replaceAll/commit/f666051cb7d2d3392d2ba30dfad952048ff47d5b) | ||
- non-global regexes throw, pending web compatibility data [`fbd9a60`](https://github.com/es-shims/String.prototype.replaceAll/commit/fbd9a60c929575111721f9c71d5638804614ba21) | ||
- [fix] add fallback for pre-Symbol.replace engines [`57b33d3`](https://github.com/es-shims/String.prototype.replaceAll/commit/57b33d3dbb8348f2b9e83a652a1771c447e953e8) | ||
- [Tests] add `npm run lint` [`a979c0f`](https://github.com/es-shims/String.prototype.replaceAll/commit/a979c0fc27735abb3a710ae80be5c5c564a5d1fe) | ||
- [meta] add auto-changelog [`f780972`](https://github.com/es-shims/String.prototype.replaceAll/commit/f78097211dcc9a22f805f4198026ee87a41d14e1) | ||
- Only apps should have lockfiles [`b9dc48f`](https://github.com/es-shims/String.prototype.replaceAll/commit/b9dc48f43711a8d38515aeafdd0ffc6a985465bc) |
'use strict'; | ||
var ES = require('es-abstract/es2019'); | ||
var Call = require('es-abstract/2019/Call'); | ||
var GetMethod = require('es-abstract/2019/GetMethod'); | ||
var GetSubstitution = require('es-abstract/2019/GetSubstitution'); | ||
var IsCallable = require('es-abstract/2019/IsCallable'); | ||
var IsInteger = require('es-abstract/2019/IsInteger'); | ||
var RequireObjectCoercible = require('es-abstract/2019/RequireObjectCoercible'); | ||
var ToString = require('es-abstract/2019/ToString'); | ||
var Type = require('es-abstract/2019/Type'); | ||
var GetIntrinsic = require('es-abstract/GetIntrinsic'); | ||
@@ -17,9 +24,9 @@ var callBound = require('es-abstract/helpers/callBound'); | ||
// TODO: replace this with the es-abstract impl once it's merged and published | ||
// TODO: replace this with the es-abstract 2020 impl once it's merged and published | ||
// eslint-disable-next-line max-params, func-style | ||
function StringIndexOf(string, searchValue, fromIndex) { | ||
if (ES.Type(string) !== 'String' || ES.Type(searchValue) !== 'String') { | ||
if (Type(string) !== 'String' || Type(searchValue) !== 'String') { | ||
throw new $TypeError('Assertion failed: string and searchValue must both be Strings'); | ||
} | ||
if (!ES.IsInteger(fromIndex) || fromIndex < 0) { | ||
if (!IsInteger(fromIndex) || fromIndex < 0) { | ||
throw new $TypeError('Assertion failed: fromIndex must be a nonnegative integer'); | ||
@@ -40,3 +47,3 @@ } | ||
module.exports = function replaceAll(searchValue, replaceValue) { | ||
var O = ES.RequireObjectCoercible(this); | ||
var O = RequireObjectCoercible(this); | ||
@@ -50,5 +57,5 @@ var searchValueIsRegex = isRegex(searchValue); | ||
if (searchValue != null) { | ||
var replacer = ES.GetMethod(searchValue, Symbol.replace); | ||
var replacer = GetMethod(searchValue, Symbol.replace); | ||
if (typeof replacer !== 'undefined') { | ||
return ES.Call(replacer, searchValue, [O, replaceValue]); | ||
return Call(replacer, searchValue, [O, replaceValue]); | ||
} | ||
@@ -60,7 +67,7 @@ } | ||
var string = ES.ToString(O); | ||
var searchString = ES.ToString(searchValue); | ||
var functionalReplace = ES.IsCallable(replaceValue); | ||
var string = ToString(O); | ||
var searchString = ToString(searchValue); | ||
var functionalReplace = IsCallable(replaceValue); | ||
if (!functionalReplace) { | ||
replaceValue = ES.ToString(replaceValue); // eslint-disable-line no-param-reassign | ||
replaceValue = ToString(replaceValue); // eslint-disable-line no-param-reassign | ||
} | ||
@@ -88,9 +95,9 @@ | ||
if (functionalReplace) { | ||
replacement = ES.ToString(ES.Call(replaceValue, undefined, [searchString, matchPositions[i], string])); | ||
replacement = ToString(Call(replaceValue, undefined, [searchString, matchPositions[i], string])); | ||
} else { | ||
if (ES.Type(replaceValue) !== 'String') { | ||
if (Type(replaceValue) !== 'String') { | ||
throw new $TypeError('Assertion failed: `replaceValue` should be a string at this point'); | ||
} | ||
var captures = []; | ||
replacement = ES.GetSubstitution(searchString, string, matchPositions[i], captures, undefined, replaceValue); | ||
replacement = GetSubstitution(searchString, string, matchPositions[i], captures, undefined, replaceValue); | ||
} | ||
@@ -97,0 +104,0 @@ var stringSlice = $slice(string, endOfLastMatch, matchPositions[i]); |
'use strict'; | ||
var bind = require('function-bind'); | ||
var callBind = require('es-abstract/helpers/callBind'); | ||
var define = require('define-properties'); | ||
@@ -10,3 +10,3 @@ | ||
var boundReplaceAll = bind.call(Function.call, implementation); | ||
var boundReplaceAll = callBind(implementation); | ||
@@ -13,0 +13,0 @@ define(boundReplaceAll, { |
{ | ||
"name": "string.prototype.replaceall", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Spec-compliant polyfill for String.prototype.replaceAll ESnext proposal", | ||
@@ -35,2 +35,5 @@ "main": "index.js", | ||
"author": "Jordan Harband <ljharb@gmail.com>", | ||
"funding": { | ||
"url": "https://github.com/sponsors/ljharb" | ||
}, | ||
"license": "MIT", | ||
@@ -43,7 +46,7 @@ "bugs": { | ||
"@es-shims/api": "^2.1.2", | ||
"@ljharb/eslint-config": "^14.1.0", | ||
"auto-changelog": "^1.16.1", | ||
"@ljharb/eslint-config": "^15.0.2", | ||
"auto-changelog": "^1.16.2", | ||
"es5-shim": "^4.5.13", | ||
"es6-shim": "^0.35.5", | ||
"eslint": "^6.6.0", | ||
"eslint": "^6.7.2", | ||
"evalmd": "^0.0.19", | ||
@@ -54,5 +57,5 @@ "functions-have-names": "^1.2.0" | ||
"define-properties": "^1.1.3", | ||
"es-abstract": "^1.16.0", | ||
"es-abstract": "^1.17.0-next.1", | ||
"function-bind": "^1.1.1", | ||
"has-symbols": "^1.0.0", | ||
"has-symbols": "^1.0.1", | ||
"is-regex": "^1.0.4" | ||
@@ -62,7 +65,7 @@ }, | ||
"output": "CHANGELOG.md", | ||
"template": "keepachangelog", | ||
"unreleased": false, | ||
"commitLimit": false, | ||
"backfillLimit": false, | ||
"template": "keepachangelog" | ||
"backfillLimit": false | ||
} | ||
} |
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
174
17847
Updatedes-abstract@^1.17.0-next.1
Updatedhas-symbols@^1.0.1