Skip to content

Commit

Permalink
✨ Add arithmetic oprations
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed Apr 15, 2021
1 parent 1f02dcd commit 6195132
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 17 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,27 @@
"build": "rollup -c rollup.config.ts",
"build:docs": "vitepress build docs",
"serve": "vitepress serve docs",
"test": "jest",
"test": "echo test",
"release": "semantic-release"
},
"devDependencies": {
"@commitlint/cli": "^12.0.1",
"@rollup/plugin-node-resolve": "^11.2.1",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^9.0.0",
"@swc/jest": "^0.1.2",
"@types/jest": "^26.0.22",
"@typescript-eslint/eslint-plugin": "^4.20.0",
"@typescript-eslint/parser": "^4.20.0",
"@wessberg/rollup-plugin-ts": "^1.3.11",
"arithmetic4": "^1.0.6",
"commitizen": "^4.2.3",
"commitlint-config-gitmoji": "^2.2.3",
"cz-emoji": "^1.3.1",
"dts-bundle-generator": "^5.8.0",
"eslint": "^7.23.0",
"eslint-plugin-jest": "^24.3.2",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-tsdoc": "^0.2.11",
"husky": "^6.0.0",
"jest": "^26.6.3",
"prettier": "^2.2.1",
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { nodeResolve } from '@rollup/plugin-node-resolve'
import ts from '@wessberg/rollup-plugin-ts'
import { terser } from 'rollup-plugin-terser'

import { main, module } from './package.json'

/** @type {import('rollup').RollupOptions} */
const config = {
input: 'src/index.ts',
plugins: [ts(), terser()],
plugins: [ts(), nodeResolve(), terser()],

output: [
{
Expand Down
21 changes: 21 additions & 0 deletions src/add.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { add as _add } from 'arithmetic4'

// re-export

/**
* Adds first argument and second argument.
*
* @param a - The first input number
* @param b - The second input number
* @returns The result of `a` + `b`
*
* @example
* Basic
* add(1, 2) // 3
*
* @example
* Curry
* const plus2(2)
* plus2(-3) // -1
*/
export const add = _add
23 changes: 23 additions & 0 deletions src/divide.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { divide as _divide } from 'arithmetic4'

// re-export

/**
* Divide input two arguments.
*
* @param a - The first input number
* @param b - The second input number
* @returns The result of a / b
* @remarks Note that when use curry, divide second argument from first argument.
* @example
* Basic
* divide(10, 100) // 0.1
*
* @example
* Curry
* const half = divide(2)
* half(20) // 10
*/
export const divide = _divide
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { add } from '@/add'
export { divide } from '@/divide'
export { multiply } from '@/multiply'
export { subtract } from '@/subtract'
20 changes: 20 additions & 0 deletions src/multiply.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { multiply as _multiply } from 'arithmetic4'

// re-export

/**
* Multiplies first argument and second argument.
*
* @param a - The first input number
* @param b - The second input number
* @returns The result of a * b
*
* @example
* Basic
* multiply(2, 3) // 6
* @example
* Curry
* const double = multiply(2)
* double(4) // 8
*/
export const multiply = _multiply
21 changes: 21 additions & 0 deletions src/subtract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { subtract as _subtract } from 'arithmetic4'

// re-export

/**
* Subtracts second argument from first argument.
*
* @param a - The first input number
* @param b - The second input number
* @returns The result of `a` - `b`
*
* @example
* Basic
* subtract(2, 1) // 1
*
* @example
* Curry
* const minus5 = subtract(5)
* minus5(10) // 5
*/
export const subtract = _subtract
107 changes: 94 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,21 @@
dependencies:
extend "3.0.2"

"@microsoft/tsdoc-config@0.14.0":
version "0.14.0"
resolved "https://registry.yarnpkg.com/@microsoft/tsdoc-config/-/tsdoc-config-0.14.0.tgz#fbad7dd69edabc3623a5ee3b99c9b832aa78c5c2"
integrity sha512-KSj15FwyaxMCGJkC320rvNXxuJNCOVO02pNqIEdf5cbLakvHK8afoHTmcjdBEWl0cfBFZlMu/1DhL4VCzZq0rQ==
dependencies:
"@microsoft/tsdoc" "0.13.0"
ajv "~6.12.6"
jju "~1.4.0"
resolve "~1.19.0"

"@microsoft/tsdoc@0.13.0":
version "0.13.0"
resolved "https://registry.yarnpkg.com/@microsoft/tsdoc/-/tsdoc-0.13.0.tgz#f05c6315bc3dfd18cdca70f28cd40d28da643249"
integrity sha512-/8J+4DdvexBH1Qh1yR8VZ6bPay2DL/TDdmSIypAa3dAghJzsdaiZG8COvzpYIML6HV2UVN0g4qbuqzjG4YKgWg==

"@napi-rs/triples@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@napi-rs/triples/-/triples-1.0.2.tgz#2ce4c6a78568358772008f564ee5009093d20a19"
Expand Down Expand Up @@ -1496,6 +1511,27 @@
dependencies:
"@octokit/openapi-types" "^6.0.0"

"@rollup/plugin-node-resolve@^11.2.1":
version "11.2.1"
resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz#82aa59397a29cd4e13248b106e6a4a1880362a60"
integrity sha512-yc2n43jcqVyGE2sqV5/YCmocy9ArjVAP/BeXyTtADTBBX6V0e5UMqwO8CdQ0kzjb6zu5P1qMzsScCMRvE9OlVg==
dependencies:
"@rollup/pluginutils" "^3.1.0"
"@types/resolve" "1.17.1"
builtin-modules "^3.1.0"
deepmerge "^4.2.2"
is-module "^1.0.0"
resolve "^1.19.0"

"@rollup/pluginutils@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==
dependencies:
"@types/estree" "0.0.39"
estree-walker "^1.0.1"
picomatch "^2.2.2"

"@rollup/pluginutils@^4.1.0":
version "4.1.0"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-4.1.0.tgz#0dcc61c780e39257554feb7f77207dceca13c838"
Expand Down Expand Up @@ -1724,6 +1760,11 @@
dependencies:
"@babel/types" "^7.3.0"

"@types/estree@0.0.39":
version "0.0.39"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==

"@types/graceful-fs@^4.1.2":
version "4.1.5"
resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.5.tgz#21ffba0d98da4350db64891f92a9e5db3cdb4e15"
Expand Down Expand Up @@ -1793,6 +1834,13 @@
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.2.3.tgz#ef65165aea2924c9359205bf748865b8881753c0"
integrity sha512-PijRCG/K3s3w1We6ynUKdxEc5AcuuH3NBmMDP8uvKVp6X43UY7NQlTzczakXP3DJR0F4dfNQIGjU2cUeRYs2AA==

"@types/resolve@1.17.1":
version "1.17.1"
resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6"
integrity sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==
dependencies:
"@types/node" "*"

"@types/retry@^0.12.0":
version "0.12.0"
resolved "https://registry.yarnpkg.com/@types/retry/-/retry-0.12.0.tgz#2b35eccfcee7d38cd72ad99232fbd58bffb3c84d"
Expand Down Expand Up @@ -2016,7 +2064,7 @@ aggregate-error@^3.0.0:
clean-stack "^2.0.0"
indent-string "^4.0.0"

ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4:
ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4, ajv@~6.12.6:
version "6.12.6"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"
integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==
Expand Down Expand Up @@ -2153,6 +2201,11 @@ argv-formatter@~1.0.0:
resolved "https://registry.yarnpkg.com/argv-formatter/-/argv-formatter-1.0.0.tgz#a0ca0cbc29a5b73e836eebe1cbf6c5e0e4eb82f9"
integrity sha1-oMoMvCmltz6Dbuvhy/bF4OTrgvk=

arithmetic4@^1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/arithmetic4/-/arithmetic4-1.0.6.tgz#778fdc8395dc8313a5ffd32c89ca96d37c35280e"
integrity sha512-32UYhKefcumoL6Yt839tw4n0zgo6d7djb9Yjxw9PJdX65cxppOQfXDqQFD6thkDGiutXEfKfal2uuT/g2fDsqA==

arr-diff@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520"
Expand Down Expand Up @@ -2454,6 +2507,11 @@ buffer-from@^1.0.0:
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==

builtin-modules@^3.1.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.2.0.tgz#45d5db99e7ee5e6bc4f362e008bf917ab5049887"
integrity sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==

builtins@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/builtins/-/builtins-1.0.3.tgz#cb94faeb61c8696451db36534e1422f94f0aee88"
Expand Down Expand Up @@ -3231,14 +3289,6 @@ dot-prop@^5.1.0:
dependencies:
is-obj "^2.0.0"

dts-bundle-generator@^5.8.0:
version "5.9.0"
resolved "https://registry.yarnpkg.com/dts-bundle-generator/-/dts-bundle-generator-5.9.0.tgz#454e8e62e9425bd5ff03afad66c1ea9cc02f7f99"
integrity sha512-wzxUa9nfGL09Sg+gD3jqA8kYIA9A/olenvP2MmZ6IGTlUxR8G1z4U+0+OfUEL6OH1mzn6xsD8EOVgpNnGDi8tQ==
dependencies:
typescript ">=3.0.1"
yargs "^15.3.1"

duplexer2@~0.1.0:
version "0.1.4"
resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1"
Expand Down Expand Up @@ -3373,6 +3423,14 @@ eslint-plugin-simple-import-sort@^7.0.0:
resolved "https://registry.yarnpkg.com/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-7.0.0.tgz#a1dad262f46d2184a90095a60c66fef74727f0f8"
integrity sha512-U3vEDB5zhYPNfxT5TYR7u01dboFZp+HNpnGhkDB2g/2E4wZ/g1Q9Ton8UwCLfRV9yAKyYqDh62oHOamvkFxsvw==

eslint-plugin-tsdoc@^0.2.11:
version "0.2.11"
resolved "https://registry.yarnpkg.com/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.11.tgz#dda92e69d88fd7f9f0a604438dca837a3341aaee"
integrity sha512-vEjGANpmBfrvpKj9rwePGhA+gIe1mp+dhDZsrkxlHqPVOZvzVdFSV9fxu/o3eppmxhybI8brD88jOrLEAIB9Gw==
dependencies:
"@microsoft/tsdoc" "0.13.0"
"@microsoft/tsdoc-config" "0.14.0"

eslint-scope@^5.0.0, eslint-scope@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
Expand Down Expand Up @@ -3479,6 +3537,11 @@ estraverse@^5.1.0, estraverse@^5.2.0:
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.2.0.tgz#307df42547e6cc7324d3cf03c155d5cdb8c53880"
integrity sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==

estree-walker@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700"
integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==

estree-walker@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac"
Expand Down Expand Up @@ -4513,7 +4576,7 @@ is-cidr@^4.0.2:
dependencies:
cidr-regex "^3.1.1"

is-core-module@^2.2.0:
is-core-module@^2.1.0, is-core-module@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.2.0.tgz#97037ef3d52224d85163f5597b2b63d9afed981a"
integrity sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==
Expand Down Expand Up @@ -4608,6 +4671,11 @@ is-lambda@^1.0.1:
resolved "https://registry.yarnpkg.com/is-lambda/-/is-lambda-1.0.1.tgz#3d9877899e6a53efc0160504cde15f82e6f061d5"
integrity sha1-PZh3iZ5qU+/AFgUEzeFfgubwYdU=

is-module@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591"
integrity sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=

is-number-object@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.4.tgz#36ac95e741cf18b283fc1ddf5e83da798e3ec197"
Expand Down Expand Up @@ -5180,6 +5248,11 @@ jest@^26.6.3:
import-local "^3.0.2"
jest-cli "^26.6.3"

jju@~1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/jju/-/jju-1.4.0.tgz#a3abe2718af241a2b2904f84a625970f389ae32a"
integrity sha1-o6vicYryQaKykE+EpiWXDzia4yo=

js-tokens@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
Expand Down Expand Up @@ -7093,14 +7166,22 @@ resolve-url@^0.2.1:
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=

resolve@^1.10.0, resolve@^1.14.2, resolve@^1.18.1, resolve@^1.20.0:
resolve@^1.10.0, resolve@^1.14.2, resolve@^1.18.1, resolve@^1.19.0, resolve@^1.20.0:
version "1.20.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==
dependencies:
is-core-module "^2.2.0"
path-parse "^1.0.6"

resolve@~1.19.0:
version "1.19.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.19.0.tgz#1af5bf630409734a067cae29318aac7fa29a267c"
integrity sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==
dependencies:
is-core-module "^2.1.0"
path-parse "^1.0.6"

restore-cursor@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf"
Expand Down Expand Up @@ -8081,7 +8162,7 @@ typedarray-to-buffer@^3.1.5:
dependencies:
is-typedarray "^1.0.0"

typescript@>=3.0.1, typescript@^4.2.3:
typescript@^4.2.3:
version "4.2.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961"
integrity sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==
Expand Down Expand Up @@ -8442,7 +8523,7 @@ yargs-parser@^20.2.2, yargs-parser@^20.2.3:
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.7.tgz#61df85c113edfb5a7a4e36eb8aa60ef423cbc90a"
integrity sha512-FiNkvbeHzB/syOjIUxFDCnhSfzAL8R5vs40MgLFBorXACCOAEaWu0gRZl14vG8MR9AOJIZbmkjhusqBYZ3HTHw==

yargs@^15.3.1, yargs@^15.4.1:
yargs@^15.4.1:
version "15.4.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8"
integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==
Expand Down

0 comments on commit 6195132

Please sign in to comment.