Skip to content

Commit

Permalink
feat: add split function
Browse files Browse the repository at this point in the history
  • Loading branch information
kantord committed Oct 19, 2018
1 parent 6870e1d commit dbd53e9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"analyze": "yarn build --json | tac | tac | tail -n +3 > stats.json",
"analyze-bundle":
"yarn analyze && yarn webpack-bundle-analyzer stats.json lib/",
"test": "jest src",
"test": "jest ./src",
"build": "yarn webpack && yarn babel src/ -d lib/",
"test:eslint": "yarn eslint src",
"test:flow": "yarn flow check",
Expand Down
10 changes: 9 additions & 1 deletion src/__tests__/builtins.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const {
reduce,
length,
keys,
values,
split,
values
} = builtIns

describe('built ins', () => {
Expand Down Expand Up @@ -50,6 +51,13 @@ describe('built ins', () => {
})
})

describe('split', () => {
it('returns correct value', () => {
expect(split(' ')('Hello World')).toEqual(['Hello', 'World'])
expect(split(',')('Hello World')).toEqual(['Hello World'])
})
})

describe('map', () => {
it('returns correct value', () => {
const id = a => a; // eslint-disable-line
Expand Down
4 changes: 4 additions & 0 deletions src/builtins.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export default {
? handleProjection(left)(right)[0]
: handleProjection(left)(right),

split: (separator: string): (string => Array<string>) => (
input: string
): Array<string> => input.split(separator),

join: (separator: string): ((Array<string>) => string) => (
input: Array<string>
): string => input.join(separator),
Expand Down

0 comments on commit dbd53e9

Please sign in to comment.