Skip to content

Commit

Permalink
upgrade packages
Browse files Browse the repository at this point in the history
  • Loading branch information
ktalebian committed Apr 3, 2020
1 parent 156ac85 commit 574fdbb
Show file tree
Hide file tree
Showing 8 changed files with 4,919 additions and 2,479 deletions.
8 changes: 8 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": [
"twilio-ts"
],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
}
7,211 changes: 4,827 additions & 2,384 deletions package-lock.json

Large diffs are not rendered by default.

23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"prebuild": "rm -rf build",
"build": "tsc",
"coverage": "codecov",
"lint": "tslint --project tsconfig.lint.json",
"lint:fix": "tslint --project tsconfig.lint.json --fix",
"lint": "eslint --ext ts src/",
"lint:fix": "npm run lint -- --fix",
"test": "jest",
"test:watch": "jest --watch"
},
Expand All @@ -34,15 +34,16 @@
},
"dependencies": {},
"devDependencies": {
"@types/jest": "^24.0.15",
"@types/node": "^12.6.2",
"codecov": "^3.5.0",
"husky": "^3.0.0",
"jest": "^24.8.0",
"ts-jest": "^24.0.2",
"ts-node": "^8.3.0",
"tslint": "^5.18.0",
"typescript": "^3.5.3"
"@types/jest": "^25.1.5",
"@types/node": "^13.11.0",
"codecov": "^3.6.5",
"eslint": "^6.8.0",
"eslint-config-twilio-ts": "^1.22.0",
"husky": "^4.2.3",
"jest": "^25.2.7",
"ts-jest": "^25.3.1",
"ts-node": "^8.8.1",
"typescript": "^3.8.3"
},
"reveal": true
}
115 changes: 58 additions & 57 deletions src/index.spec.ts
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),
);
});
});
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export const pipe = (x: any, ...fns: Function[]) => fns.reduce((v, f) => f(v), x
export const compose = (x: any, ...fns: Function[]) => fns.reduceRight((v, f) => f(v), x);
export const cPipe = (...fns: Function[]) => (x: any) => pipe(x, ...fns);
export const cCompose = (...fns: Function[]) => (x: any) => compose(x, ...fns);
export const pPipe = (...fns: PromiseFunction[]) => async (x: any) => fns.reduce(async (v, f) => f(await v), x);
export const pCompose = (...fns: PromiseFunction[]) => async (x: any) => fns.reduceRight(async (v, f) => f(await v), x);
export const pPipe = (...fns: PromiseFunction[]) => async (x: any) => fns.reduce(async (v, f) => f(await v), x);
export const pCompose = (...fns: PromiseFunction[]) => async (x: any) => fns.reduceRight(async (v, f) => f(await v), x);
13 changes: 0 additions & 13 deletions tsconfig.base.json

This file was deleted.

15 changes: 12 additions & 3 deletions tsconfig.json
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"
]
}
9 changes: 0 additions & 9 deletions tsconfig.lint.json

This file was deleted.

0 comments on commit 574fdbb

Please sign in to comment.