Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

string-replace-all

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-replace-all - npm Package Compare versions

Comparing version
1.0.3
to
2.0.0
license

Sorry, the diff of this file is not supported yet

+25
# stringReplaceAll
Replaces all the occurrences of a string into a string with another string.
## Install
```shell
$ npm install --save string-replace-all
```
## Usage
```js
import stringReplaceAll from 'string-replace-all';
stringReplaceAll ( 'A tiny tiny tiger', 'tiny', 'small' ); // 'A small small tiger'
```
## Related
- [string-matches](https://github.com/fabiospampinato/string-matches) - Retrieves all the matches of a regex in a string.
## License
MIT © Fabio Spampinato
+0
-3

@@ -11,4 +11,1 @@

trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

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

declare function stringReplaceAll(str: string, find: string, replacement: string): string;
declare const _default: typeof stringReplaceAll & {
default: typeof stringReplaceAll;
}
declare namespace _default {
export type type = typeof stringReplaceAll;
}
export = _default;
declare const replaceAll: (str: string, find: string, replacement: string) => string;
export default replaceAll;

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

"use strict";
/* IMPORT */
var escapeRegExp = require("lodash/escapeRegExp");
/* STRING REPLACE ALL */
function stringReplaceAll(str, find, replacement) {
return str.replace(new RegExp(escapeRegExp(find), 'g'), replacement);
}
import escape from 'string-escape-regex';
/* MAIN */
const replaceAll = (str, find, replacement) => {
return str.replace(new RegExp(escape(find), 'g'), replacement);
};
/* EXPORT */
module.exports = stringReplaceAll;
module.exports.default = stringReplaceAll;
Object.defineProperty(module.exports, "__esModule", { value: true });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUNBLFlBQVk7O0FBRVosa0RBQXdEO0FBRXhELHdCQUF3QjtBQUV4QixTQUFTLGdCQUFnQixDQUFHLEdBQVcsRUFBRSxJQUFZLEVBQUUsV0FBbUI7SUFFeEUsT0FBTyxHQUFHLENBQUMsT0FBTyxDQUFHLElBQUksTUFBTSxDQUFHLFlBQVksQ0FBRyxJQUFJLENBQUUsRUFBRSxHQUFHLENBQUUsRUFBRSxXQUFXLENBQUUsQ0FBQztBQUVoRixDQUFDO0FBRUQsWUFBWTtBQUVaLGtCQUFlLGdCQUFnQixDQUFDIn0=
export default replaceAll;
{
"name": "string-replace-all",
"version": "1.0.3",
"repository": "github:fabiospampinato/string-replace-all",
"description": "Replaces all the occurrences of a string into a string with another string.",
"version": "2.0.0",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"clean:dist": "rimraf dist",
"clean:coverage": "rimraf coverage .nyc_output",
"clean": "npm run clean:dist && npm run clean:coverage",
"compile": "tsc --skipLibCheck && tstei",
"compile:watch": "tsc --skipLibCheck --watch",
"test": "ava",
"test:watch": "ava --watch",
"coverage": "nyc --reporter=html ava",
"report": "nyc report",
"report:html": "open coverage/index.html",
"prepublishOnly": "npm run clean && npm run compile && npm run coverage"
"clean": "tsex clean",
"compile": "tsex compile",
"compile:watch": "tsex compile --watch",
"test": "tsex test",
"test:watch": "tsex test --watch",
"prepublishOnly": "npm run clean && npm run compile && npm run test"
},
"ava": {
"files": [
"test/index.js"
]
},
"bugs": {
"url": "https://github.com/fabiospampinato/string-replace-all/issues"
},
"license": "MIT",
"author": {
"name": "Fabio Spampinato",
"email": "spampinabio@gmail.com"
},
"repository": {
"type": "git",
"url": "https://github.com/fabiospampinato/string-replace-all.git"
},
"keywords": [

@@ -43,13 +24,9 @@ "string",

"dependencies": {
"@types/lodash": "^4.14.58",
"lodash": "^4.17.4"
"string-escape-regex": "^1.0.0"
},
"devDependencies": {
"ava": "^0.18.2",
"ava-spec": "^1.1.0",
"nyc": "^10.1.2",
"rimraf": "^2.6.0",
"typescript": "~3.0.3",
"typescript-transform-export-interop": "^1.0.0"
"fava": "^0.0.6",
"tsex": "^1.1.2",
"typescript": "^4.6.4"
}
}
/* IMPORT */
import escapeRegExp = require ( 'lodash/escapeRegExp' );
import escape from 'string-escape-regex';
/* STRING REPLACE ALL */
/* MAIN */
function stringReplaceAll ( str: string, find: string, replacement: string ): string {
const replaceAll = ( str: string, find: string, replacement: string ): string => {
return str.replace ( new RegExp ( escapeRegExp ( find ), 'g' ), replacement );
return str.replace ( new RegExp ( escape ( find ), 'g' ), replacement );
}
};
/* EXPORT */
export default stringReplaceAll;
export default replaceAll;
/* IMPORT */
import {describe} from 'ava-spec';
import stringReplaceAll from '../dist';
import {describe} from 'fava';
import stringReplaceAll from '../dist/index.js';
/* STRING REPLACE ALL */
/* MAIN */

@@ -9,0 +9,0 @@ describe ( 'stringReplaceAll', it => {

{
"compilerOptions": {
"alwaysStrict": true,
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"inlineSourceMap": true,
"lib": ["dom", "scripthost", "es2015", "es2016", "es2017"],
"module": "commonjs",
"moduleResolution": "node",
"newLine": "LF",
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": false,
"outDir": "dist",
"pretty": true,
"strictNullChecks": true,
"target": "es5"
},
"include": [
"src"
],
"exclude": [
"node_modules"
]
"extends": "tsex/tsconfig.json"
}
The MIT License (MIT)
Copyright (c) 2017-present Fabio Spampinato
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
# stringReplaceAll
Replaces all the occurrences of a string into a string with another string.
## Install
```shell
$ npm install --save string-replace-all
```
## Usage
```js
import stringReplaceAll from 'string-replace-all';
stringReplaceAll ( 'A tiny tiny tiger', 'tiny', 'small' ); // 'A small small tiger'
```
## Related
- [string-matches](https://github.com/fabiospampinato/string-matches) - Retrieves all the matches of a regex in a string.
## License
MIT © Fabio Spampinato