-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
4,919 additions
and
2,479 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": [ | ||
"twilio-ts" | ||
], | ||
"rules": { | ||
"@typescript-eslint/no-explicit-any": "off" | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,81 @@ | ||
import { cCompose, compose, cPipe, pCompose, pipe, pPipe } from './index'; | ||
import { cCompose, compose, cPipe, pCompose, pipe, pPipe } from '.'; | ||
|
||
describe('index', () => { | ||
const uppercase = (str: string) => str.toUpperCase(); | ||
const reverse = (str: string) => str.split('').reverse().join(''); | ||
const get3Chars = (str: string) => str.substring(0, 3); | ||
const uppercase = (str: string) => str.toUpperCase(); | ||
const reverse = (str: string) => str.split('').reverse().join(''); | ||
const get3Chars = (str: string) => str.substring(0, 3); | ||
|
||
const add1 = async (current: number) => current + 1; | ||
const divide3 = async (current: number) => current / 3; | ||
const multiply2 = async (current: number) => current * 2; | ||
const add1 = async (current: number) => current + 1; | ||
const divide3 = async (current: number) => current / 3; | ||
const multiply2 = async (current: number) => current * 2; | ||
|
||
describe('pipe', () => { | ||
it('should return result without any functions', () => { | ||
expect(pipe('sample-argument')).toEqual('sample-argument'); | ||
}); | ||
|
||
it('should pipe', () => { | ||
expect(pipe('sample-argument', uppercase, get3Chars, reverse)).toEqual('MAS'); | ||
expect(pipe('sample-argument', uppercase, reverse, get3Chars)).toEqual('TNE'); | ||
}); | ||
describe('pipe', () => { | ||
it('should return result without any functions', () => { | ||
expect(pipe('sample-argument')).toEqual('sample-argument'); | ||
}); | ||
|
||
describe('compose', () => { | ||
it('should return result without any functions', () => { | ||
expect(compose('sample-argument')).toEqual('sample-argument'); | ||
}); | ||
it('should pipe', () => { | ||
expect(pipe('sample-argument', uppercase, get3Chars, reverse)).toEqual('MAS'); | ||
expect(pipe('sample-argument', uppercase, reverse, get3Chars)).toEqual('TNE'); | ||
}); | ||
}); | ||
|
||
it('should compose', () => { | ||
expect(compose('sample-argument', uppercase, get3Chars, reverse)).toEqual('TNE'); | ||
expect(compose('sample-argument', uppercase, reverse, get3Chars)).toEqual('MAS'); | ||
}); | ||
describe('compose', () => { | ||
it('should return result without any functions', () => { | ||
expect(compose('sample-argument')).toEqual('sample-argument'); | ||
}); | ||
|
||
describe('cPipe', () => { | ||
it('should return result without any functions', () => { | ||
expect(cPipe()('sample-argument')).toEqual('sample-argument'); | ||
}); | ||
it('should compose', () => { | ||
expect(compose('sample-argument', uppercase, get3Chars, reverse)).toEqual('TNE'); | ||
expect(compose('sample-argument', uppercase, reverse, get3Chars)).toEqual('MAS'); | ||
}); | ||
}); | ||
|
||
it('should pipe', () => { | ||
expect(cPipe(uppercase, get3Chars, reverse)('sample-argument')).toEqual('MAS'); | ||
expect(cPipe(uppercase, reverse, get3Chars)('sample-argument')).toEqual('TNE'); | ||
}); | ||
describe('cPipe', () => { | ||
it('should return result without any functions', () => { | ||
expect(cPipe()('sample-argument')).toEqual('sample-argument'); | ||
}); | ||
|
||
describe('cCompose', () => { | ||
it('should return result without any functions', () => { | ||
expect(cCompose()('sample-argument')).toEqual('sample-argument'); | ||
}); | ||
it('should pipe', () => { | ||
expect(cPipe(uppercase, get3Chars, reverse)('sample-argument')).toEqual('MAS'); | ||
expect(cPipe(uppercase, reverse, get3Chars)('sample-argument')).toEqual('TNE'); | ||
}); | ||
}); | ||
|
||
it('should compose', () => { | ||
expect(cCompose(uppercase, get3Chars, reverse)('sample-argument')).toEqual('TNE'); | ||
expect(cCompose(uppercase, reverse, get3Chars)('sample-argument')).toEqual('MAS'); | ||
}); | ||
describe('cCompose', () => { | ||
it('should return result without any functions', () => { | ||
expect(cCompose()('sample-argument')).toEqual('sample-argument'); | ||
}); | ||
|
||
describe('pPipe', () => { | ||
it('should return value if no functions', async () => { | ||
expect(await pPipe()(1)).toEqual(1); | ||
}); | ||
it('should compose', () => { | ||
expect(cCompose(uppercase, get3Chars, reverse)('sample-argument')).toEqual('TNE'); | ||
expect(cCompose(uppercase, reverse, get3Chars)('sample-argument')).toEqual('MAS'); | ||
}); | ||
}); | ||
|
||
it('should pipe promises', async () => { | ||
expect(await pPipe(add1, multiply2, divide3)(2)).toEqual(2); | ||
}); | ||
describe('pPipe', () => { | ||
it('should return value if no functions', async () => { | ||
expect(await pPipe()(1)).toEqual(1); | ||
}); | ||
|
||
describe('pCompose', () => { | ||
it('should return value if no functions', async () => { | ||
expect(await pCompose()(1)).toEqual(1); | ||
}); | ||
it('should pipe promises', async () => { | ||
expect(await pPipe(add1, multiply2, divide3)(2)).toEqual(2); | ||
}); | ||
}); | ||
|
||
it('should pipe promises', async () => { | ||
expect(await pCompose(add1, multiply2, divide3)(6)).toEqual(5); | ||
}); | ||
describe('pCompose', () => { | ||
it('should return value if no functions', async () => { | ||
expect(await pCompose()(1)).toEqual(1); | ||
}); | ||
|
||
it('pipe and compose', () => { | ||
expect(compose('sample-argument', uppercase, get3Chars, reverse)) | ||
.toEqual(pipe('sample-argument', reverse, get3Chars, uppercase)); | ||
it('should pipe promises', async () => { | ||
expect(await pCompose(add1, multiply2, divide3)(6)).toEqual(5); | ||
}); | ||
}); | ||
|
||
it('pipe and compose', () => { | ||
expect(compose('sample-argument', uppercase, get3Chars, reverse)).toEqual( | ||
pipe('sample-argument', reverse, get3Chars, uppercase), | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
{ | ||
"extends": "./tsconfig.base.json", | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"rootDir": "src", | ||
"target": "es5", | ||
"module": "commonjs", | ||
"outDir": "build", | ||
"sourceMap": true, | ||
"declaration": true, | ||
"strict": false, | ||
"removeComments": true, | ||
}, | ||
"include": [ | ||
"src/**/*" | ||
], | ||
"exclude": [ | ||
"node_modules", | ||
"src/**/*.spec.ts" | ||
"node_modules" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.