Skip to content

Commit

Permalink
feat(split): implement splitAF method
Browse files Browse the repository at this point in the history
Closes #37
  • Loading branch information
ScottRudiger committed May 19, 2018
1 parent c2e2028 commit 24c9ee4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/methods/strings/splitAF.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const splitAF = function (separator = undefined, limit = undefined) {
return this.then(str => {
if (typeof str !== 'string' || Array.isArray(str))
throw TypeError(`splitAF may be called on a string but was called on ${str}`);
return String.prototype.split.call(str, separator, limit);
});
};

export default splitAF;
14 changes: 13 additions & 1 deletion packageList.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const staticMethods = [
| PROTOTYPE METHODS |
|____________________________| */

// Arrays:
// Arrays
import mapAF from './lib/methods/arrays/mapAF';
import forEachAF from './lib/methods/arrays/forEachAF';
import filterAF from './lib/methods/arrays/filterAF';
Expand Down Expand Up @@ -66,8 +66,20 @@ const arrayMethods = [
makeScoped(method.name),
]);

// strings
import splitAF from './lib/methods/strings/splitAF';

const stringMethods = [
splitAF,
].map(method => [
method,
`${libPath}methods/strings/${method.name}`,
makeScoped(method.name),
]);

const prototypeMethods = [
...arrayMethods,
...stringMethods,
];

/* ____________________________
Expand Down

0 comments on commit 24c9ee4

Please sign in to comment.