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

chai-string

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai-string - npm Package Compare versions

Comparing version 1.1.6 to 1.2.0

.npmignore

55

chai-string.js

@@ -21,4 +21,10 @@ (function (plugin) {

function isString(value) {
return typeof value === 'string';
}
chai.string.startsWith = function (str, prefix) {
if (!isString(str) || !isString(prefix)) {
return false;
}
return str.indexOf(prefix) === 0;

@@ -28,2 +34,5 @@ };

chai.string.endsWith = function (str, suffix) {
if (!isString(str) || !isString(suffix)) {
return false;
}
return str.indexOf(suffix, str.length - suffix.length) !== -1;

@@ -33,2 +42,5 @@ };

chai.string.equalIgnoreCase = function (str1, str2) {
if (!isString(str1) || !isString(str2)) {
return false;
}
return str1.toLowerCase() === str2.toLowerCase();

@@ -38,2 +50,5 @@ };

chai.string.equalIgnoreSpaces = function (str1, str2) {
if (!isString(str1) || !isString(str2)) {
return false;
}
return str1.replace(/\s/g, '') === str2.replace(/\s/g, '');

@@ -43,2 +58,5 @@ };

chai.string.singleLine = function(str) {
if (!isString(str)) {
return false;
}
return str.trim().indexOf("\n") === -1;

@@ -48,2 +66,5 @@ };

chai.string.reverseOf = function(str, reversed) {
if (!isString(str) || !isString(reversed)) {
return false;
}
return str.split('').reverse().join('') === reversed;

@@ -53,2 +74,5 @@ };

chai.string.palindrome = function(str) {
if (!isString(str)) {
return false;
}
var len = str.length;

@@ -64,14 +88,16 @@ for ( var i = 0; i < Math.floor(len/2); i++ ) {

chai.string.entriesCount = function(str, substr, count) {
var i = 0,
len = str.length,
matches = 0;
while (i < len) {
var indx = str.indexOf(substr, i);
if (indx === -1) {
break;
var matches = 0;
if (isString(str) && isString(substr)) {
var i = 0;
var len = str.length;
while (i < len) {
var indx = str.indexOf(substr, i);
if (indx === -1) {
break;
}
else {
matches++;
i = indx + 1;
}
}
else {
matches++;
i = indx + 1;
}
}

@@ -82,3 +108,4 @@ return matches === count;

chai.string.indexOf = function(str, substr, index) {
return str.indexOf(substr) === index;
var indx = !isString(str) || !isString(substr) ? -1 : str.indexOf(substr);
return indx === index;
};

@@ -243,8 +270,8 @@

new chai.Assertion(str, msg).to.have.entriesCount(substr, count);
}
};
assert.indexOf = function(str, substr, index, msg) {
new chai.Assertion(str, msg).to.have.indexOf(substr, index);
}
};
}));
{
"name": "chai-string",
"version": "1.1.6",
"version": "1.2.0",
"keywords": ["chai", "testing", "string", "chai-plugin", "browser"],

@@ -8,3 +8,3 @@ "description": "strings comparison matchers for chai",

"scripts": {
"test": "make test"
"test": "mocha test"
},

@@ -22,4 +22,3 @@ "repository": {

"chai": ">=1.9.1",
"mocha": ">=1.6.0",
"nodemon": ">=0.6.23"
"mocha": ">=1.6.0"
},

@@ -26,0 +25,0 @@ "peerDependencies": {

@@ -0,0 +0,0 @@ # chai-string

@@ -69,2 +69,8 @@ (function (test) {

it('should return false (2)', function () {
var str = '12abcdef',
prefix = 12.0;
chai.string.startsWith(str, prefix).should.be.false;
});
it('check that', function () {

@@ -91,2 +97,9 @@ var obj = { foo: 'hello world' };

it('should return false (2)', function () {
var str = '12abcdef',
prefix = 12.0;
str.should.not.startWith(prefix);
chai.string.startsWith(str, prefix).should.be.false;
});
});

@@ -108,2 +121,8 @@

it('should return false (2)', function () {
var str = 'abcdef12',
suffix = 12.0;
chai.string.endsWith(str, suffix).should.be.false;
});
});

@@ -125,2 +144,8 @@

it('should return false (2)', function () {
var str = 'abcdef12',
suffix = 12.0;
str.should.not.endsWith(suffix);
});
});

@@ -142,2 +167,14 @@

it('should return false (2)', function () {
var str1 = 12,
str2 = '12';
chai.string.equalIgnoreCase(str1, str2).should.be.false;
});
it('should return false (3)', function () {
var str1 = '12',
str2 = 12;
chai.string.equalIgnoreCase(str1, str2).should.be.false;
});
});

@@ -159,2 +196,10 @@

it('should return false (2)', function () {
chai.string.equalIgnoreSpaces('12', 12).should.be.false;
});
it('should return false (3)', function () {
chai.string.equalIgnoreSpaces(12, '12').should.be.false;
});
});

@@ -174,2 +219,6 @@

it('should return false (2)', function() {
chai.string.singleLine(12).should.be.false;
});
});

@@ -191,2 +240,10 @@

it('should return false (2)', function () {
chai.string.reverseOf('12', 12).should.be.false;
});
it('should return false (3)', function () {
chai.string.reverseOf(12, '12').should.be.false;
});
});

@@ -216,2 +273,6 @@

it('should return false (2)', function() {
chai.string.palindrome(12).should.be.false;
});
});

@@ -242,2 +303,23 @@

it('should return true (4)', function() {
var str = 12,
substr = 'ab',
count = 0;
chai.string.entriesCount(str, substr, count).should.be.true;
});
it('should return true (5)', function() {
var str = '12',
substr = 12,
count = 0;
chai.string.entriesCount(str, substr, count).should.be.true;
});
it('should return false ', function() {
var str = '12',
substr = 12,
count = 1;
chai.string.entriesCount(str, substr, count).should.be.false;
});
});

@@ -268,2 +350,16 @@

it('should return true (4)', function() {
var str = '12',
substr = 12,
index = -1;
chai.string.indexOf(str, substr, index).should.be.true;
});
it('should return true (5)', function() {
var str = 12,
substr = '12',
index = -1;
chai.string.indexOf(str, substr, index).should.be.true;
});
it('should return false', function() {

@@ -276,2 +372,16 @@ var str = 'abcaab',

it('should return false (2)', function() {
var str = '12',
substr = 12,
index = 0;
chai.string.indexOf(str, substr, index).should.be.false;
});
it('should return false (3)', function() {
var str = 12,
substr = '12',
index = 0;
chai.string.indexOf(str, substr, index).should.be.false;
});
});

@@ -295,2 +405,6 @@

it('.notStartsWith (2)', function () {
assert.notStartsWith('12abc', 12.0);
});
it('.endsWith', function () {

@@ -304,2 +418,6 @@ assert.endsWith(this.str, 'def');

it('.notEndsWith (2)', function () {
assert.notEndsWith('abc12', 12.0);
});
it('.equalIgnoreCase', function () {

@@ -313,2 +431,10 @@ assert.equalIgnoreCase(this.str, 'AbCdEf');

it('.notEqualIgnoreCase (2)', function () {
assert.notEqualIgnoreCase('12', 12);
});
it('.notEqualIgnoreCase (3)', function () {
assert.notEqualIgnoreCase(12, '12');
});
it('.equalIgnoreSpaces', function () {

@@ -322,2 +448,10 @@ assert.equalIgnoreSpaces(this.str, this.str2);

it('.notEqualIgnoreSpaces (2)', function () {
assert.notEqualIgnoreSpaces('12', 12);
});
it('.notEqualIgnoreSpaces (3)', function () {
assert.notEqualIgnoreSpaces(12, '12');
});
it('.singleLine', function() {

@@ -331,2 +465,6 @@ assert.singleLine(this.str);

it('.notSingleLine (2)', function() {
assert.notSingleLine(12);
});
it('.reverseOf', function() {

@@ -340,2 +478,10 @@ assert.reverseOf(this.str, 'fedcba');

it('.notReverseOf (2)', function() {
assert.notReverseOf('12', 12);
});
it('.notReverseOf (3)', function() {
assert.notReverseOf(12, '12');
});
it('.palindrome', function() {

@@ -351,2 +497,6 @@ assert.palindrome('abcba');

it('.notPalindrome (2)', function() {
assert.notPalindrome(12);
});
it('.entriesCount', function() {

@@ -357,2 +507,4 @@ assert.entriesCount('abcabd', 'ab', 2);

assert.entriesCount('', 'ab', 0);
assert.entriesCount(12, 'ab', 0);
assert.entriesCount('12', 12, 0);
});

@@ -364,2 +516,5 @@

assert.indexOf('ababab', 'ba', 1);
assert.indexOf('ababab', 'ba', 1);
assert.indexOf(12, '12', -1);
assert.indexOf('12', 12, -1);
expect('ababab').to.have.indexOf('ba', 1);

@@ -366,0 +521,0 @@ });

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