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

absurdum

Package Overview
Dependencies
Maintainers
1
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

absurdum - npm Package Compare versions

Comparing version 0.15.0 to 0.15.1

2

package.json
{
"name": "absurdum",
"version": "0.15.0",
"version": "0.15.1",
"description": "Reducio Ad Absurdum - The Riduculous Application of Reduce",

@@ -5,0 +5,0 @@ "keywords": [

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

export const endsWith = (string, substr) => {
export const endsWith = (string, substr = '') => {
return string.split('').reduce((acc, curr, idx, arr) => {

@@ -6,2 +6,3 @@ // exit early on mismatch

arr = arr.splice(0);
return false;
}

@@ -14,3 +15,3 @@ // exit early on match

return acc;
}, false);
}, null);
};

@@ -23,1 +23,21 @@ import test from 'tape';

});
test(`strings.endsWith(string, substr) - returns falsy when the string doesn't end with the substr`, t => {
const expect = false;
const result = strings.endsWith('abc', 'f');
t.equal(Object.prototype.toString.call(result), '[object Boolean]', 'return type');
t.equal(result, expect, 'output value');
t.end();
});
test(`strings.endsWith(string, substr) - should not mutate the input`, t => {
const input = 'abc';
const expect = 'abc';
strings.endsWith(input, 'f');
t.equal(input, expect, 'input mutation');
t.end();
});
export const startsWith = (string, substr) => {
return string.split('').reduce((acc, curr, idx, arr) => {
let chars = string.split('');
return chars.reduce((acc, curr, idx, arr) => {
// exit early on mismatch
if (curr !== substr[idx]) {
arr = arr.splice(0);
chars = arr.splice(0);
return false;
}
// exit early on match
if (idx === substr.length - 1) {
arr = arr.splice(0);
chars = arr.splice(0);
return true;
}
return acc;
}, false);
}, null);
};

@@ -23,1 +23,21 @@ import test from 'tape';

});
test(`strings.startsWith(string, substr) - returns falsy when the string doesn't start with the substr`, t => {
const expect = false;
const result = strings.startsWith('abc', 'f');
t.equal(Object.prototype.toString.call(result), '[object Boolean]', 'return type');
t.equal(result, expect, 'output value');
t.end();
});
test(`strings.startsWith(string, substr) - should not mutate the input`, t => {
const input = 'abc';
const expect = 'abc';
strings.startsWith(input, 'f');
t.equal(input, expect, 'input mutation');
t.end();
});
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