From 824a2d9f587ca017fc71b84d835e72f54f9c87c4 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 7 Nov 2018 18:02:36 +0100 Subject: Began rewrite --- node_modules/locutus/php/strings/strripos.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 node_modules/locutus/php/strings/strripos.js (limited to 'node_modules/locutus/php/strings/strripos.js') diff --git a/node_modules/locutus/php/strings/strripos.js b/node_modules/locutus/php/strings/strripos.js new file mode 100644 index 0000000..03f60b8 --- /dev/null +++ b/node_modules/locutus/php/strings/strripos.js @@ -0,0 +1,27 @@ +'use strict'; + +module.exports = function strripos(haystack, needle, offset) { + // discuss at: http://locutus.io/php/strripos/ + // original by: Kevin van Zonneveld (http://kvz.io) + // bugfixed by: Onno Marsman (https://twitter.com/onnomarsman) + // bugfixed by: Brett Zamir (http://brett-zamir.me) + // input by: saulius + // example 1: strripos('Kevin van Zonneveld', 'E') + // returns 1: 16 + + haystack = (haystack + '').toLowerCase(); + needle = (needle + '').toLowerCase(); + + var i = -1; + if (offset) { + i = (haystack + '').slice(offset).lastIndexOf(needle); // strrpos' offset indicates starting point of range till end, + // while lastIndexOf's optional 2nd argument indicates ending point of range from the beginning + if (i !== -1) { + i += offset; + } + } else { + i = (haystack + '').lastIndexOf(needle); + } + return i >= 0 ? i : false; +}; +//# sourceMappingURL=strripos.js.map \ No newline at end of file -- cgit v1.2.3