es-string-algorithm
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -0,4 +1,52 @@ | ||
/** | ||
* Determines the lowest position `xpos`, if possible, such that both of the following conditions hold: | ||
* | ||
* 1. `pos <= xpos` and `xpos < size(target)` | ||
* 2. [`k.includes(at(target, xpos))`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) (When `n` is `undefined` (omitted), `k` is equal to `key`. Otherwise, `k` is equal to [`key.substring(0, n)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring)) | ||
* | ||
* @param target search target string | ||
* @param key string identifying characters to search for | ||
* @param pos position at which to begin searching | ||
* @param n length of character string identifying characters to search for | ||
* @returns `xpos` if the function can determine such a value for `xpos`. Otherwise, returns `-1`. | ||
*/ | ||
export declare const findFirstOf: (target: string, key: string, pos?: number, n?: number | undefined) => number; | ||
/** | ||
* Determines the highest position `xpos`, if possible, such that both of the following conditions hold: | ||
* | ||
* 1. `pos <= xpos` and `xpos < size(target)` | ||
* 2. [`k.includes(at(target, xpos))`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) (When `n` is `undefined` (omitted), `k` is equal to `key`. Otherwise, `k` is equal to [`key.substring(0, n)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring)) | ||
* | ||
* @param target search target string | ||
* @param key string identifying characters to search for | ||
* @param pos position at which the search is to finish. `-1` is equal to the length of search target string | ||
* @param n length of character string identifying characters to search for | ||
* @retunrs `xpos` if the function can determine such a value for `xpos`. Otherwise, returns `-1`. | ||
*/ | ||
export declare const findLastof: (target: string, key: string, pos?: number, n?: number | undefined) => number; | ||
/** | ||
* Determines the lowest position `xpos`, if possible, such that both of the following conditions hold: | ||
* | ||
* 1. `pos <= xpos` and `xpos < size(target)` | ||
* 2. [`!k.includes(at(target, xpos))`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) (When `n` is `undefined` (omitted), `k` is equal to `key`. Otherwise, `k` is equal to [`key.substring(0, n)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring)) | ||
* | ||
* @param target search target string | ||
* @param key string identifying characters to search for | ||
* @param pos position at which to begin searching | ||
* @param n length of character string identifying characters to search for | ||
* @returns `xpos` if the function can determine such a value for `xpos`. Otherwise, returns `-1`. | ||
*/ | ||
export declare const findFirstNotOf: (target: string, key: string, pos?: number, n?: number | undefined) => number; | ||
/** | ||
* Determines the highest position `xpos`, if possible, such that both of the following conditions hold: | ||
* | ||
* 1. `pos <= xpos` and `xpos < size(target)` | ||
* 2. [`k.includes(at(target, xpos))`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) (When `n` is `undefined` (omitted), `k` is equal to `key`. Otherwise, `k` is equal to [`key.substring(0, n)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring)) | ||
* | ||
* @param target search target string | ||
* @param key string identifying characters to search for | ||
* @param pos position at which the search is to finish. `-1` is equal to the length of search target string | ||
* @param n length of character string identifying characters to search for | ||
* @returns `xpos` if the function can determine such a value for `xpos`. Otherwise, returns `-1`. | ||
*/ | ||
export declare const findLastNotof: (target: string, key: string, pos?: number, n?: number | undefined) => number; |
@@ -13,8 +13,14 @@ "use strict"; | ||
}; | ||
// size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept; // (1) C++11 | ||
// size_type find_first_of(const charT* s, size_type pos, size_type n) const; // (2) | ||
// size_type find_first_of(const charT* s, size_type pos = 0) const; // (3) | ||
// size_type find_first_of(charT c, size_type pos = 0) const; // (4) C++11 | ||
// size_type find_first_of(std::basic_string_view<charT, traits> sv, | ||
// size_type pos = 0) const noexcept; // (5) C++17 | ||
/** | ||
* Determines the lowest position `xpos`, if possible, such that both of the following conditions hold: | ||
* | ||
* 1. `pos <= xpos` and `xpos < size(target)` | ||
* 2. [`k.includes(at(target, xpos))`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) (When `n` is `undefined` (omitted), `k` is equal to `key`. Otherwise, `k` is equal to [`key.substring(0, n)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring)) | ||
* | ||
* @param target search target string | ||
* @param key string identifying characters to search for | ||
* @param pos position at which to begin searching | ||
* @param n length of character string identifying characters to search for | ||
* @returns `xpos` if the function can determine such a value for `xpos`. Otherwise, returns `-1`. | ||
*/ | ||
exports.findFirstOf = (target, key, pos = 0, n) => findFirst(target, key, pos, (c, k) => k.includes(c), n); | ||
@@ -29,22 +35,40 @@ const findLast = (target, key, pos, pred, n) => { | ||
}; | ||
// size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept; // (1) C++11 | ||
// size_type find_last_of(const charT* s, size_type pos, size_type n) const; // (2) | ||
// size_type find_last_of(const charT* s, size_type pos = npos) const; // (3) | ||
// size_type find_last_of(charT c, size_type pos = npos) const; // (4) C++11 | ||
// size_type find_last_of(std::basic_string_view<charT, traits> sv, | ||
// size_type pos = npos) const noexcept; // (5) C++17 | ||
/** | ||
* Determines the highest position `xpos`, if possible, such that both of the following conditions hold: | ||
* | ||
* 1. `pos <= xpos` and `xpos < size(target)` | ||
* 2. [`k.includes(at(target, xpos))`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) (When `n` is `undefined` (omitted), `k` is equal to `key`. Otherwise, `k` is equal to [`key.substring(0, n)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring)) | ||
* | ||
* @param target search target string | ||
* @param key string identifying characters to search for | ||
* @param pos position at which the search is to finish. `-1` is equal to the length of search target string | ||
* @param n length of character string identifying characters to search for | ||
* @retunrs `xpos` if the function can determine such a value for `xpos`. Otherwise, returns `-1`. | ||
*/ | ||
exports.findLastof = (target, key, pos = -1, n) => findLast(target, key, pos, (c, k) => k.includes(c), n); | ||
// size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept; // (1) C++11 | ||
// size_type find_first_not_of(const charT* s, size_type pos, size_type n) const; // (2) | ||
// size_type find_first_not_of(const charT* s, size_type pos = 0) const; // (3) | ||
// size_type find_first_not_of(charT c, size_type pos = 0) const; // (4) C++11 | ||
// size_type find_first_not_of(std::basic_string_view<charT, traits> sv, | ||
// size_type pos = 0) const noexcept; // (5) C++17 | ||
/** | ||
* Determines the lowest position `xpos`, if possible, such that both of the following conditions hold: | ||
* | ||
* 1. `pos <= xpos` and `xpos < size(target)` | ||
* 2. [`!k.includes(at(target, xpos))`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) (When `n` is `undefined` (omitted), `k` is equal to `key`. Otherwise, `k` is equal to [`key.substring(0, n)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring)) | ||
* | ||
* @param target search target string | ||
* @param key string identifying characters to search for | ||
* @param pos position at which to begin searching | ||
* @param n length of character string identifying characters to search for | ||
* @returns `xpos` if the function can determine such a value for `xpos`. Otherwise, returns `-1`. | ||
*/ | ||
exports.findFirstNotOf = (target, key, pos = 0, n) => findFirst(target, key, pos, (c, k) => !k.includes(c), n); | ||
// size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept; // (1) C++11 | ||
// size_type find_last_not_of(const charT* s, size_type pos, size_type n) const; // (2) | ||
// size_type find_last_not_of(const charT* s, size_type pos = npos) const; // (3) | ||
// size_type find_last_not_of(charT c, size_type pos = npos) const; // (4) C++11 | ||
// size_type find_last_not_of(std::basic_string_view<charT, traits> sv, | ||
// size_type pos = npos) const noexcept; // (5) C++17 | ||
/** | ||
* Determines the highest position `xpos`, if possible, such that both of the following conditions hold: | ||
* | ||
* 1. `pos <= xpos` and `xpos < size(target)` | ||
* 2. [`k.includes(at(target, xpos))`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) (When `n` is `undefined` (omitted), `k` is equal to `key`. Otherwise, `k` is equal to [`key.substring(0, n)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring)) | ||
* | ||
* @param target search target string | ||
* @param key string identifying characters to search for | ||
* @param pos position at which the search is to finish. `-1` is equal to the length of search target string | ||
* @param n length of character string identifying characters to search for | ||
* @returns `xpos` if the function can determine such a value for `xpos`. Otherwise, returns `-1`. | ||
*/ | ||
exports.findLastNotof = (target, key, pos = -1, n) => findLast(target, key, pos, (c, k) => !k.includes(c), n); |
{ | ||
"name": "es-string-algorithm", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "port from C++STL std::basic_string", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.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
16546
152