string-replace-all
Advanced tools
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 |
+2
-8
@@ -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; |
+6
-10
@@ -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; |
+15
-38
| { | ||
| "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" | ||
| } | ||
| } |
+6
-6
| /* 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; |
+3
-3
| /* 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 => { |
+1
-26
| { | ||
| "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" | ||
| } |
-21
| 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. |
-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 |
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
1
-50%3
-50%0
-100%Yes
NaN3511
-38.25%31
-52.31%2
Infinity%1
Infinity%+ Added
+ Added
- Removed
- Removed
- Removed
- Removed