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.0.1 to 1.0.2

3

index.js
'use strict';
const kindOf = require('kind-of');
const _ = require('lodash');

@@ -15,3 +16,3 @@ const replaceLast = function(str, pattern, replacement) {

if (kindOf(pattern) === 'string') {
pattern = new RegExp(pattern, 'g');
pattern = new RegExp(_.escapeRegExp(pattern), 'g');
} else if (kindOf(pattern) === 'regexp') {

@@ -18,0 +19,0 @@ pattern = new RegExp(pattern.source, 'g');

{
"name": "replace-last",
"version": "1.0.1",
"version": "1.0.2",
"description": "Replaces last match for pattern in string with replacement",

@@ -24,3 +24,4 @@ "author": "Daniel Lewis BSc (Hons)",

"dependencies": {
"kind-of": "^6.0.0"
"kind-of": "^6.0.0",
"lodash": "^4.17.4"
},

@@ -27,0 +28,0 @@ "devDependencies": {

@@ -28,2 +28,8 @@ 'use strict';

});
it('contains regex chars', function() {
var replaceLast = require('../../index');
var result = replaceLast('hello . hello . hello', '.', 'bye');
imp.expect(result).to.equal('hello . hello bye hello');
});
});

@@ -59,2 +65,8 @@

});
it('contains regex chars', function() {
var replaceLast = require('../../index');
var result = replaceLast('hello . hello . hello', /./, 'bye');
imp.expect(result).to.equal('hello . hello . hellbye');
});
});

@@ -61,0 +73,0 @@

* Browserify code
* Node 4 windows failing
* Usual tidy
* escape regex string

Sorry, the diff of this file is not supported yet

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