Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

string.prototype.replaceall

es-shims447.7kMIT1.0.10

Spec-compliant polyfill for String.prototype.replaceAll ESnext proposal

string, replaceall, replace, regex, all, es2020, esnext, javascript, spec

readme

string.prototype.replaceall Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

ES Proposal spec-compliant shim for String.prototype.replaceAll. Invoke its "shim" method to shim String.prototype.replaceAll if it is unavailable or noncompliant.

This package implements the es-shim API interface. It works in an ES3-supported environment, and complies with the proposed spec.

Most common usage:

const assert = require('assert');
const replaceAll = require('string.prototype.replaceall');

const str = 'aabc';

// replaceAll and replace are the same, when given a global regex to replace
assert.equal(replaceAll(str, /a/g, 'z'), str.replace(/a/g, 'z'));

// replace, with a string, replaces once
assert.equal(str.replace('a', 'z'), 'zabc');

// replaceAll, with a string, replaces all
assert.equal(replaceAll(str, 'a', 'z'), 'zzbc');

replaceAll.shim(); // will be a no-op if not needed

// replaceAll and replace are the same, when given a global regex to replace
assert.equal(str.replaceAll(/a/g, 'z'), str.replace(/a/g, 'z'));

// replace, with a string, replaces once
assert.equal(str.replace('a', 'z'), 'zabc');

// replaceAll, with a string, replaces all
assert.equal(str.replaceAll('a', 'z'), 'zzbc');

Tests

Simply clone the repo, npm install, and run npm test

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v1.0.10 - 2024-03-19

Commits

  • [Deps] update call-bind, es-abstract, es-errors, get-intrinsic 769d1cf
  • [actions] remove redundant finisher 74bfab2
  • [Refactor] use es-object-atoms where possible 6696151
  • [meta] add missing engines.node e38cb2b
  • [Dev Deps] update tape 784df8c

v1.0.9 - 2024-02-04

Commits

  • [Deps] update call-bind, define-properties, es-abstract, get-intrinsic 9afaf70
  • [Dev Deps] update aud, npmignore, tape ca2421a
  • [Refactor] use es-errors where possible, so things that only need those do not need get-intrinsic fdad745

v1.0.8 - 2023-09-03

Commits

  • [Deps] update define-properties, es-abstract, get-intrinsic 23e1d04
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, aud, es6-shim, tape 5ee9858
  • [meta] fix npmignore integration 4e1e8a0

v1.0.7 - 2022-11-07

Commits

  • [actions] reuse common workflows 4bbf1bc
  • [meta] use npmignore to autogenerate an npmignore file c9a5e01
  • [Deps] update define-properties, es-abstract, get-intrinsic, has-symbols 6a559a7
  • [Dev Deps] update eslint, @ljharb/eslint-config, @es-shims/api, safe-publish-latest, tape 02e98d1
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, es5-shim, functions-have-names, tape bf0084f
  • [actions] update rebase action to use reusable workflow ce0e8b7
  • [actions] update codecov uploader 952e5b3

v1.0.6 - 2021-10-04

Commits

  • [Deps] update es-abstract 823d403
  • [actions] use node/install instead of node/run; use codecov action 23b0615
  • [Dev Deps] update eslint, @ljharb/eslint-config, @es-shims/api, aud, auto-changelog, es5-shim, tape f0f4be9
  • [meta] add FUNDING.yml 392afd7
  • [readme] add github actions/codecov badges e01952a
  • [Deps] update es-abstract, is-regex f763b3b
  • [Deps] update es-abstract, has-symbols 35cfd7a
  • [Dev Deps] update eslint, tape d066e34
  • [actions] update workflows c592b5d
  • [meta] use prepublishOnly script for npm 7+ bb345fd
  • [Dev Deps] update @es-shims/api 4050d23

v1.0.5 - 2021-02-22

Commits

  • [meta] do not publish github action workflow files 5bc61a7
  • [Refactor] use an explicit step for an empty string searchValue 5c0a89a
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, es5-shim, functions-have-names, tape 42c1125
  • [readme] remove travis badge ee72ded
  • [Deps] update call-bind, es-abstract, get-intrinsic, is-regex d79e8fc
  • [actions] update workflows 54098df
  • [Tests] increase coverage e9e96b6

v1.0.4 - 2020-11-21

Commits

  • [Tests] migrate tests to Github Actions a3561c7
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, es6-shim, tape 80dfacb
  • [Deps] update es-abstract, is-regex; use get-intrinsic and call-bind where applicable a956402
  • [Dev Deps] update eslint, @ljharb/eslint-config, tape, functions-have-names; add safe-publish-latest 5e469fd
  • [Tests] run nyc on all tests b5d1eeb
  • [actions] add "Allow Edits" workflow 03f0140
  • [Deps] update es-abstract, is-regex; refactor away from function-bind dadd98c
  • [Dev Deps] update es5-shim, tape 1740467
  • [Dev Deps] update auto-changelog; add aud 41ce396
  • [actions] switch Automatic Rebase workflow to pull_request_target event 77ce2cd
  • [Dev Deps] update auto-changelog, tape a13336c
  • [Tests] only audit prod deps c122c88
  • [Deps] update es-abstract f6b0048

v1.0.3 - 2019-12-14

Commits

  • [Tests] use shared travis-ci configs 410a2f8
  • [meta] rerun auto-changelog de4a904
  • [Refactor] use split-up es-abstract (71% bundle size decrease) dd62b57
  • [actions] add automatic rebasing / merge commit blocking f390fa7
  • [Deps] update es-abstract, has-symbols ff7ab0c
  • [Dev Deps] update eslint, @ljharb/eslint-config 5945afc
  • [meta] add funding field f0fdbf1

v1.0.2 - 2019-10-31

Fixed

  • [Deps] add missing define-properties #2

v1.0.1 - 2019-10-26

Fixed

  • [Fix] handle an empty string searchValue #1

Commits

  • [Deps] update es-abstract 2ab3464
  • [Tests] up to node v13.0, v12.13, v10.17 be6a236
  • [meta] use keepachangelog format f5248bb
  • [Dev Deps] update eslint, functions-have-names, auto-changelog 5be4a77
  • [Dev Deps] update eslint 376879f

v1.0.0 - 2019-09-03

Commits