From be8946a6964a133e133e9c8e69295ee1e6aaa00c Mon Sep 17 00:00:00 2001 From: xh12 <1960939421@qq.com> Date: Wed, 10 Aug 2022 16:01:25 +0000 Subject: [PATCH 01/11] =?UTF-8?q?=E5=AE=9E=E7=8E=B0add=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/add.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/add.js b/lib/add.js index 1714b95..a1712d0 100644 --- a/lib/add.js +++ b/lib/add.js @@ -1,5 +1,6 @@ -function add() { +function add(num1, num2) { // 实现该函数 + return String(BigInt(num1) + BigInt(num2)) } module.exports = add \ No newline at end of file From 586316abeb51cbf3b217004b302d76cd6624ed0a Mon Sep 17 00:00:00 2001 From: xh12 <1960939421@qq.com> Date: Thu, 11 Aug 2022 00:04:51 +0800 Subject: [PATCH 02/11] Create node.js.yml --- .github/workflows/node.js.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/node.js.yml diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..05f5588 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,31 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x, 14.x, 16.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build --if-present + - run: npm test From 54ad444c1663520e692afe95357408710f53f84e Mon Sep 17 00:00:00 2001 From: xh12 <1960939421@qq.com> Date: Thu, 11 Aug 2022 00:07:05 +0800 Subject: [PATCH 03/11] Create npm-publish-github-packages.yml --- .../workflows/npm-publish-github-packages.yml | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/npm-publish-github-packages.yml diff --git a/.github/workflows/npm-publish-github-packages.yml b/.github/workflows/npm-publish-github-packages.yml new file mode 100644 index 0000000..42f900b --- /dev/null +++ b/.github/workflows/npm-publish-github-packages.yml @@ -0,0 +1,36 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages + +name: Node.js Package + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - run: npm ci + - run: npm test + + publish-gpr: + needs: build + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: https://npm.pkg.github.com/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} From 65bd85dbf8b693ee049a8fd572b62d470eab0572 Mon Sep 17 00:00:00 2001 From: xh12 <1960939421@qq.com> Date: Wed, 10 Aug 2022 16:10:45 +0000 Subject: [PATCH 04/11] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/node.js.yml | 31 ---------------- .../workflows/npm-publish-github-packages.yml | 36 ------------------- 2 files changed, 67 deletions(-) delete mode 100644 .github/workflows/node.js.yml delete mode 100644 .github/workflows/npm-publish-github-packages.yml diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml deleted file mode 100644 index 05f5588..0000000 --- a/.github/workflows/node.js.yml +++ /dev/null @@ -1,31 +0,0 @@ -# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - -name: Node.js CI - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - build: - - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [12.x, 14.x, 16.x] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - run: npm ci - - run: npm run build --if-present - - run: npm test diff --git a/.github/workflows/npm-publish-github-packages.yml b/.github/workflows/npm-publish-github-packages.yml deleted file mode 100644 index 42f900b..0000000 --- a/.github/workflows/npm-publish-github-packages.yml +++ /dev/null @@ -1,36 +0,0 @@ -# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created -# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages - -name: Node.js Package - -on: - release: - types: [created] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - - run: npm ci - - run: npm test - - publish-gpr: - needs: build - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - registry-url: https://npm.pkg.github.com/ - - run: npm ci - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} From a2ac3e30b1a4af0855b44444c58d3001407e9147 Mon Sep 17 00:00:00 2001 From: xh12 <1960939421@qq.com> Date: Sat, 20 Aug 2022 06:59:26 +0000 Subject: [PATCH 05/11] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/add.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/add.js b/lib/add.js index a1712d0..544b271 100644 --- a/lib/add.js +++ b/lib/add.js @@ -1,6 +1,21 @@ function add(num1, num2) { // 实现该函数 - return String(BigInt(num1) + BigInt(num2)) + // 利用BigInt + // return String(BigInt(num1) + BigInt(num2)) + // 字符串截取进位 + const safeLength = 14; + let a = num1; + let b = num2; // 保留一份参数值 + let flag = 0, // 进位标识 + res = ''; // 结果 + while(a.length || b.length || flag) { + const andSum = String(parseInt(a.substr(-safeLength) || 0, 10) + parseInt(b.substr(-safeLength) || 0, 10)); + res = parseInt(andSum.substr(-safeLength) || 0, 10) + flag + res; + flag = andSum.length > safeLength; + a = a.substr(0, a.length - safeLength); + b = b.substr(0, b.length - safeLength); + } + return res } module.exports = add \ No newline at end of file From 8b8adad84edb64e54665e0f2940d081590408651 Mon Sep 17 00:00:00 2001 From: xh12 <1960939421@qq.com> Date: Sat, 20 Aug 2022 15:09:01 +0800 Subject: [PATCH 06/11] Create npm-publish.yml --- .github/workflows/npm-publish.yml | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..c461c85 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,33 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages + +name: Node.js Package + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - run: npm ci + - run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} From e05bdbc2b30684677db21cec8ddb5c316b059f2c Mon Sep 17 00:00:00 2001 From: xh12 <1960939421@qq.com> Date: Sat, 20 Aug 2022 15:10:41 +0800 Subject: [PATCH 07/11] Create node.js.yml --- .github/workflows/node.js.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/node.js.yml diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..05f5588 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,31 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x, 14.x, 16.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build --if-present + - run: npm test From cf01301790970c42ef02bf9c8f57ec649900d421 Mon Sep 17 00:00:00 2001 From: xh12 <1960939421@qq.com> Date: Sat, 20 Aug 2022 15:11:43 +0800 Subject: [PATCH 08/11] Delete npm-publish.yml --- .github/workflows/npm-publish.yml | 33 ------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml deleted file mode 100644 index c461c85..0000000 --- a/.github/workflows/npm-publish.yml +++ /dev/null @@ -1,33 +0,0 @@ -# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created -# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages - -name: Node.js Package - -on: - release: - types: [created] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - - run: npm ci - - run: npm test - - publish-npm: - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - registry-url: https://registry.npmjs.org/ - - run: npm ci - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} From 082bd9a574795a7ce314e0a1171b38b6c31054e1 Mon Sep 17 00:00:00 2001 From: xh12 <1960939421@qq.com> Date: Sat, 20 Aug 2022 15:13:20 +0800 Subject: [PATCH 09/11] Update node.js.yml --- .github/workflows/node.js.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 05f5588..d86d7ac 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -26,6 +26,6 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'npm' - - run: npm ci - - run: npm run build --if-present - - run: npm test + - run: npm + # 运行测试 + - run: npm test-once From b49a2aa239ec297c239809de488f6d942d4281d4 Mon Sep 17 00:00:00 2001 From: xh12 <1960939421@qq.com> Date: Sat, 20 Aug 2022 15:16:03 +0800 Subject: [PATCH 10/11] Update node.js.yml --- .github/workflows/node.js.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index d86d7ac..3d5c408 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - node-version: [12.x, 14.x, 16.x] + node-version: [16.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: @@ -25,7 +25,6 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - cache: 'npm' - - run: npm + - run: yarn # 运行测试 - - run: npm test-once + - run: yarn test-once From 530e1e735742bcf5f706a23a49ee6bca18558246 Mon Sep 17 00:00:00 2001 From: xh12 <1960939421@qq.com> Date: Sat, 20 Aug 2022 15:19:14 +0800 Subject: [PATCH 11/11] Update node.js.yml --- .github/workflows/node.js.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 3d5c408..02dfa92 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -27,4 +27,4 @@ jobs: node-version: ${{ matrix.node-version }} - run: yarn # 运行测试 - - run: yarn test-once + - run: yarn test