From 36196743483807ef86f72249d9d2943148add075 Mon Sep 17 00:00:00 2001 From: Dong Nguyen Date: Sat, 26 Oct 2024 16:05:36 +0700 Subject: [PATCH] Update linting format --- .github/workflows/ci-test.yml | 1 - .github/workflows/codeql-analysis.yml | 70 +++++++++++++-------------- README.md | 10 ++-- mod.ts | 40 ++++++++------- 4 files changed, 63 insertions(+), 58 deletions(-) diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index 4deb3c0..2c4c91a 100755 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -7,7 +7,6 @@ on: [push, pull_request] jobs: test: - runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 102df5a..61206c1 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -2,12 +2,12 @@ name: "CodeQL" on: push: - branches: [ main ] + branches: [main] pull_request: # The branches below must be a subset of the branches above - branches: [ main ] + branches: [main] schedule: - - cron: '33 18 * * 3' + - cron: "33 18 * * 3" jobs: analyze: @@ -21,39 +21,39 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'javascript' ] + language: ["javascript"] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: - - name: Checkout repository - uses: actions/checkout@v4 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + - name: Checkout repository + uses: actions/checkout@v4 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/README.md b/README.md index 4e45c2f..86912da 100755 --- a/README.md +++ b/README.md @@ -113,12 +113,12 @@ for (let i = 0; i < 5; i++) { ```html ``` diff --git a/mod.ts b/mod.ts index 5d37f7b..7be2d4c 100644 --- a/mod.ts +++ b/mod.ts @@ -1,52 +1,58 @@ // mod.ts -import { hasProperty, isArray, isObject, isString, isDate } from "./utils/detection.ts"; +import { + hasProperty, + isArray, + isDate, + isObject, + isString, +} from "./utils/detection.ts"; export type AnyObject = { [key: string]: any }; export const clone = (val: any, history: any = null): any => { - const stack = history || new Set() + const stack = history || new Set(); if (stack.has(val)) { - return val + return val; } - stack.add(val) + stack.add(val); if (isDate(val)) { - return new Date(val.valueOf()) + return new Date(val.valueOf()); } const copyObject = (o: any): any => { - const oo = Object.create({}) + const oo = Object.create({}); for (const k in o) { if (hasProperty(o, k)) { - oo[k] = clone(o[k], stack) + oo[k] = clone(o[k], stack); } } - return oo - } + return oo; + }; const copyArray = (a: any): any => { return [...a].map((e: any): any => { if (isArray(e)) { - return copyArray(e) + return copyArray(e); } else if (isObject(e)) { - return copyObject(e) + return copyObject(e); } - return clone(e, stack) - }) - } + return clone(e, stack); + }); + }; if (isArray(val)) { - return copyArray(val) + return copyArray(val); } if (isObject(val)) { - return copyObject(val) + return copyObject(val); } - return val + return val; }; export function copies(