Comparing version 0.5.0 to 0.6.0
@@ -76,5 +76,9 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/************************************************************************/ | ||
/******/ ({ | ||
/***/ 5: | ||
/******/ ([ | ||
/* 0 */, | ||
/* 1 */, | ||
/* 2 */, | ||
/* 3 */, | ||
/* 4 */, | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -89,4 +93,13 @@ | ||
var _startsWith = __webpack_require__(6); | ||
var _endsWith = __webpack_require__(6); | ||
Object.defineProperty(exports, 'endsWith', { | ||
enumerable: true, | ||
get: function get() { | ||
return _endsWith.endsWith; | ||
} | ||
}); | ||
var _startsWith = __webpack_require__(7); | ||
Object.defineProperty(exports, 'startsWith', { | ||
@@ -100,4 +113,28 @@ enumerable: true, | ||
/***/ }), | ||
/* 6 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/***/ 6: | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var endsWith = exports.endsWith = function endsWith(string, substr) { | ||
return string.split('').reduce(function (acc, curr, idx, arr) { | ||
// exit early on mismatch | ||
if (arr[arr.length - idx - 1] !== substr[substr.length - idx - 1]) { | ||
arr = arr.splice(0); | ||
} | ||
// exit early on match | ||
if (idx === substr.length - 1) { | ||
arr = arr.splice(0); | ||
return true; | ||
} | ||
return acc; | ||
}, false); | ||
}; | ||
/***/ }), | ||
/* 7 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -127,5 +164,4 @@ | ||
/***/ }) | ||
/******/ }); | ||
/******/ ]); | ||
}); | ||
//# sourceMappingURL=strings.js.map |
@@ -5,2 +5,18 @@ # Type: String | ||
### strings.endsWith(string, substr) | ||
EndsWith tests a string to see if it ends with a substring | ||
```javascript | ||
let result = strings.endsWith('This sentence ends with', 'with'); | ||
console.log(result); | ||
> true | ||
``` | ||
```javascript | ||
let result = strings.endsWith('This sentence does not end with', 'nope'); | ||
console.log(result); | ||
> false | ||
``` | ||
### strings.startsWith(string, substr) | ||
@@ -7,0 +23,0 @@ |
{ | ||
"name": "absurdum", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Reductio Ad Absurdum - The Riduculous Application of Reduce", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -70,5 +70,7 @@ [![npm](https://img.shields.io/npm/v/absurdum.svg)](https://www.npmjs.com/package/absurdum) | ||
- [endsWith][str-endswith] | ||
- [startsWith][str-startswith] | ||
[strings]: ./docs/strings.md | ||
[str-endswith]: ./docs/strings.md#stringsendswithstring-substr | ||
[str-startswith]: ./docs/strings.md#stringsstartswithstring-substr | ||
@@ -75,0 +77,0 @@ |
@@ -0,1 +1,2 @@ | ||
export { endsWith } from './endsWith'; | ||
export { startsWith } from './startsWith'; |
@@ -16,1 +16,14 @@ const test = require('tape'); | ||
}); | ||
test('strings.endsWith(array) - checks to see if the input ends with a string', (t) => { | ||
let result = strings.endsWith('This sentence ends with', 'with'); | ||
let expect = true; | ||
t.equal(Object.prototype.toString.call(result), '[object Boolean]', 'type'); | ||
t.equal(result, expect, 'value match'); | ||
result = strings.endsWith('This sentence does not end with', 'nope'); | ||
expect = false; | ||
t.equal(Object.prototype.toString.call(result), '[object Boolean]', 'type'); | ||
t.equal(result, expect, 'value mismatch'); | ||
t.end(); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
33281
29
448
85