Comparing version 0.34.0 to 0.35.0
@@ -681,2 +681,35 @@ 'use strict'; | ||
/** | ||
* IndexOf method returns the first index at which a given element can be found in the string | ||
* beyond the starting index, or -1 if it is not present. | ||
* | ||
* @param {String} string input string | ||
* @param {String} substr string to be searched for in the string | ||
* @param {Number} [start=0] index of string to begin searching for substr | ||
* @returns {Number} an integer representing the first index in the string that contains the substr | ||
* @example | ||
* const result = strings.indexOf("Lisa Browne", "Brow"); | ||
* console.log(result); | ||
* > 5 | ||
* @example | ||
* const result = strings.indexOf('fire earth, fire sky', 'fire', 1); | ||
* console.log(result); | ||
* > 12 | ||
*/ | ||
function indexOf$1 (string, substr, start = 0) { | ||
if (string.length === 0) return -1; | ||
const len = substr.length; | ||
const first = substr.charAt(0); | ||
return string.split('').reduce((res, cur, i) => { | ||
if (i >= start) { | ||
if (res > 0) { return res; } | ||
if (cur === first) { | ||
return string.substring(i, i + len) === substr ? i : -1; | ||
} | ||
} | ||
return res; | ||
}, -1); | ||
} | ||
/** | ||
* Pads the end of a string w/ repeated spaces|substrings | ||
@@ -853,2 +886,3 @@ * | ||
includes: includes, | ||
indexOf: indexOf$1, | ||
padEnd: padEnd, | ||
@@ -855,0 +889,0 @@ padStart: padStart, |
@@ -677,2 +677,35 @@ /** | ||
/** | ||
* IndexOf method returns the first index at which a given element can be found in the string | ||
* beyond the starting index, or -1 if it is not present. | ||
* | ||
* @param {String} string input string | ||
* @param {String} substr string to be searched for in the string | ||
* @param {Number} [start=0] index of string to begin searching for substr | ||
* @returns {Number} an integer representing the first index in the string that contains the substr | ||
* @example | ||
* const result = strings.indexOf("Lisa Browne", "Brow"); | ||
* console.log(result); | ||
* > 5 | ||
* @example | ||
* const result = strings.indexOf('fire earth, fire sky', 'fire', 1); | ||
* console.log(result); | ||
* > 12 | ||
*/ | ||
function indexOf$1 (string, substr, start = 0) { | ||
if (string.length === 0) return -1; | ||
const len = substr.length; | ||
const first = substr.charAt(0); | ||
return string.split('').reduce((res, cur, i) => { | ||
if (i >= start) { | ||
if (res > 0) { return res; } | ||
if (cur === first) { | ||
return string.substring(i, i + len) === substr ? i : -1; | ||
} | ||
} | ||
return res; | ||
}, -1); | ||
} | ||
/** | ||
* Pads the end of a string w/ repeated spaces|substrings | ||
@@ -849,2 +882,3 @@ * | ||
includes: includes, | ||
indexOf: indexOf$1, | ||
padEnd: padEnd, | ||
@@ -851,0 +885,0 @@ padStart: padStart, |
{ | ||
"name": "absurdum", | ||
"version": "0.34.0", | ||
"version": "0.35.0", | ||
"description": "Reductio Ad Absurdum - The Ridiculous Application of Reduce", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -109,2 +109,3 @@ [![GitHub Releases](https://img.shields.io/github/release/vanillaes/absurdum.svg)](https://github.com/vanillaes/absurdum/releases) | ||
- [includes][strings.includes] | ||
- [indexOf][strings.indexOf] | ||
- [padEnd][strings.padEnd] | ||
@@ -118,2 +119,3 @@ - [padStart][strings.padStart] | ||
[strings.includes]: ./docs/strings/includes.md | ||
[strings.indexOf]: ./docs/strings/indexOf.md | ||
[strings.padEnd]: ./docs/strings/padEnd.md | ||
@@ -120,0 +122,0 @@ [strings.padStart]: ./docs/strings/padStart.md |
export { endsWith } from "./endsWith.js"; | ||
export { includes } from "./includes.js"; | ||
export { indexOf } from "./indexOf.js"; | ||
export { padEnd } from "./padEnd.js"; | ||
@@ -4,0 +5,0 @@ export { padStart } from "./padStart.js"; |
export { endsWith } from './endsWith.js'; | ||
export { includes } from './includes.js'; | ||
export { indexOf } from './indexOf.js'; | ||
export { padEnd } from './padEnd.js'; | ||
@@ -4,0 +5,0 @@ export { padStart } from './padStart.js'; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
129182
112
3240
132