Socket
Socket
Sign inDemoInstall

prototypes

Package Overview
Dependencies
1
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.3 to 0.1.4

47

lib/string.js

@@ -44,2 +44,31 @@ 'use strict';

/**
* Find out if the string contains the argument at any position.
*/
newString.contains = function(str)
{
return this.indexOf(str) != -1;
};
/**
* Find out if the string contains the argument at any position,
* ignoring case.
*/
newString.containsIgnoreCase = function(str)
{
return this.toLowerCase().indexOf(str.toLowerCase()) != -1;
};
/**
* Test contains.
*/
function testContains(callback)
{
testing.assert('abcde'.contains('bcd'), 'Contains included', callback);
testing.assert(!'abcde'.contains('dcb'), 'Not contains excluded', callback);
testing.assert('abCDe'.containsIgnoreCase('BcD'), 'Contains ignore case included', callback);
testing.assert(!'aBCde'.containsIgnoreCase('DcB'), 'Not contains ignore case excluded', callback);
testing.success(callback);
}
/**
* Return the piece of string until the argument is found.

@@ -109,20 +138,2 @@ * 'hi.there'.substringUpTo('.') => 'hi'

/**
* Find out if the string contains the argument at any position.
*/
newString.contains = function(str)
{
return this.indexOf(str) != -1;
};
/**
* Test contains.
*/
function testContains(callback)
{
testing.assert('abcde'.contains('bcd'), 'Contains included', callback);
testing.assert(!'abcde'.contains('dcb'), 'Not contains excluded', callback);
testing.success(callback);
}
/**
* Replace all occurrences of a string with the replacement.

@@ -129,0 +140,0 @@ */

{
"name": "prototypes",
"version": "0.1.3",
"version": "0.1.4",
"description": "Some common prototypes for node.js: string.startsWith(), object.countProperties() and more. Functions are added using Object.defineProperty() to avoid polluting new objects.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/alexfernandez/prototypes",

@@ -89,2 +89,11 @@ [![Build Status](https://secure.travis-ci.org/alexfernandez/prototypes.png)](http://travis-ci.org/alexfernandez/prototypes)

### string.containsIgnoreCase(str)
Find out if the string contains the argument at any position,
ignoring case.
Example:
'aBcDe'.contains('bCd');
\=> true
### string.replaceAll(str, replacement)

@@ -91,0 +100,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc