metarhia-common
Advanced tools
Comparing version 0.0.18 to 0.0.19
@@ -203,2 +203,26 @@ 'use strict'; | ||
const section = ( | ||
// Splits string by the first occurrence of separator | ||
s, // String | ||
separator // char or String | ||
// Example: rsection('All you need is JavaScript', 'is') | ||
// Returns: ['All you need ', ' JavaScript'] | ||
) => { | ||
const i = s.indexOf(separator); | ||
if (i < 0) return [s, '']; | ||
return [s.slice(0, i), s.slice(i + separator.length)]; | ||
}; | ||
const rsection = ( | ||
// Splits string by the last occurrence of separator | ||
s, // String | ||
separator // char or String | ||
// Example: rsection('All you need is JavaScript', 'a') | ||
// Returns: ['All you need is Jav', 'Script'] | ||
) => { | ||
const i = s.lastIndexOf(separator); | ||
if (i < 0) return [s, '']; | ||
return [s.slice(0, i), s.slice(i + separator.length)]; | ||
}; | ||
module.exports = { | ||
@@ -219,2 +243,4 @@ subst, | ||
arrayRegExp, | ||
section, | ||
rsection, | ||
}; |
{ | ||
"name": "metarhia-common", | ||
"version": "0.0.18", | ||
"version": "0.0.19", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "Metarhia Common Library", |
@@ -421,2 +421,16 @@ # Metarhia Common Library | ||
## Splits string by the first occurrence of separator | ||
`common.section` | ||
- `s` - String | ||
- `separator` - char or String | ||
- Example: rsection('All you need is JavaScript', 'is') | ||
- Returns: ['All you need ', ' JavaScript'] | ||
## Splits string by the last occurrence of separator | ||
`commin.rsection` | ||
- `s` - String | ||
- `separator` - char or String | ||
- Example: rsection('All you need is JavaScript', 'a') | ||
- Returns: ['All you need is Jav', 'Script'] | ||
## Contributors | ||
@@ -423,0 +437,0 @@ |
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
60977
36
1671
440