Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

replace-last

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

replace-last - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

NOTES.md

2

benchmarks/index.js

@@ -0,1 +1,3 @@

'use strict';
var assert = require('assert');

@@ -2,0 +4,0 @@ var now = require('performance-now');

@@ -53,2 +53,3 @@ 'use strict';

function replaceLast(str, pattern, replacement) {
if (str == null) str = '';
str = '' + str;

@@ -55,0 +56,0 @@ if (typeof replacement === 'undefined') return str;

5

js/replaceLast.spec.js

@@ -184,4 +184,5 @@ 'use strict';

var results = resultsFromArgs(undefined, 'hello', 'bye');
expect(results.result).to.equal('undefined');
expect(results.lodashResult).to.equal(''); // inconsistent result, prefer 'undefined'
expect(results.result).to.equal('');
expect(results.lodashResult).to.equal('');
expect(results.result).to.equal(results.lodashResult);
});

@@ -188,0 +189,0 @@

{
"name": "replace-last",
"version": "1.2.2",
"version": "1.2.3",
"description": "JavaScript replaceLast function - Replaces last match for pattern in string with replacement",

@@ -35,6 +35,6 @@ "author": "danday74",

"replace last",
"replace",
"last",
"regex",
"string",
"replace",
"last",
"lodash",

@@ -41,0 +41,0 @@ "underscore"

@@ -47,3 +47,3 @@ # replace-last

str (string): The string to modify.
str='' (string): The string to modify.

@@ -85,3 +85,3 @@ pattern (RegExp|string): The pattern to replace.

[REVELATION 22:12-13 AMP](https://www.bible.com/en-GB/bible/1588/REV.22.12-13.amp "Jesus loves you")
[Revelation 22:12-13 AMP](https://www.bible.com/en-GB/bible/1588/REV.22.12-13.amp "Jesus loves you")

@@ -88,0 +88,0 @@ Jesus, King of Kings (**first**) put himself **last** - paying the death penalty for your wrongdoing - by willingly dying on the cross for you in your place.

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

var replaceLast=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){"use strict";function r(t,e,n,r){return t.substring(0,r)+n+t.substring(r+e.length,t.length)}function o(t,e,n){for(var o,i=(e=function(t){var e=-1===t.flags.indexOf("g")?t.flags+"g":t.flags;return new RegExp(t.source,e)}(e)).exec(t);null!=i;)o=i,i=e.exec(t);if(null==o)return t;if(1===o.length)return r(t,o[0],n,o.index);for(var c=o[0],f=1;f<o.length;f++)c=u(c,o[f],n);return r(t,o[0],c,o.index)}function u(t,e,n){var o=t.lastIndexOf(e);return o<0?t:r(t,e,n,o)}t.exports=function(t,e,n){return t=""+t,void 0===n?t:(r=e,"[object RegExp]"===Object.prototype.toString.call(r)?o(t,e,n):u(t,e=""+e,n));var r}},function(t,e,n){"use strict";const r=n(0);t.exports=function(t,e,n){return void 0===RegExp.prototype.flags&&Object.defineProperty(RegExp.prototype,"flags",{configurable:!0,get:function(){return this.toString().match(/[gimuy]*$/)[0]}}),r(t,e,n)}}]);
var replaceLast=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){"use strict";function r(t,e,n,r){return t.substring(0,r)+n+t.substring(r+e.length,t.length)}function o(t,e,n){for(var o,i=(e=function(t){var e=-1===t.flags.indexOf("g")?t.flags+"g":t.flags;return new RegExp(t.source,e)}(e)).exec(t);null!=i;)o=i,i=e.exec(t);if(null==o)return t;if(1===o.length)return r(t,o[0],n,o.index);for(var c=o[0],f=1;f<o.length;f++)c=u(c,o[f],n);return r(t,o[0],c,o.index)}function u(t,e,n){var o=t.lastIndexOf(e);return o<0?t:r(t,e,n,o)}t.exports=function(t,e,n){return null==t&&(t=""),t=""+t,void 0===n?t:(r=e,"[object RegExp]"===Object.prototype.toString.call(r)?o(t,e,n):u(t,e=""+e,n));var r}},function(t,e,n){"use strict";const r=n(0);t.exports=function(t,e,n){return void 0===RegExp.prototype.flags&&Object.defineProperty(RegExp.prototype,"flags",{configurable:!0,get:function(){return this.toString().match(/[gimuy]*$/)[0]}}),r(t,e,n)}}]);

@@ -1,19 +0,5 @@

Benchmark code against alternative solutions to same problem
Consider:
negative lookahead - https://stackoverflow.com/questions/49372598/using-negative-lookahead-regex-abc-abc-versus-abc-abc
str.match with g flag and take last
regex.exec with g flag and take last
Update README
Tidy code
Test browser usage
Check packages
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