diff --git a/.github/workflows/CD.yaml b/.github/workflows/CD.yaml new file mode 100644 index 0000000..87083f6 --- /dev/null +++ b/.github/workflows/CD.yaml @@ -0,0 +1,24 @@ +name: CD +on: + pull_request: + types: [ closed ] + +jobs: + publish-to-registry: + if: github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Print ENV + run: | + echo ${ github.event.pull_request.base.ref } + echo ${ github.event.pull_request } + + # - name: Publish to Registry + # uses: JS-DevTools/npm-publish@v3 + # with: + # token: ${{ secrets.NPM_TOKEN }} + \ No newline at end of file diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 7a5502b..d355aee 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -1,9 +1,5 @@ name: CI on: - push: - branches: - - "!main" - - "*" pull_request: branches: - "dev" diff --git a/README.md b/README.md index f0dcb33..391b1f5 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ JS challenge by @thdxr on X.com


`n-tuple-array` solution code
-[](./assets/demo-classic.svg) +[](https://github.com/chalu/n-tuple-array/blob/main/src/demo/demo-classic.ts#L6-L40)

`n-tuple-array` n-tuple-array solution demo
@@ -56,12 +56,13 @@ JS challenge by @thdxr on X.com
## Setup & Usage ```bash -npm install n-tuple-array +npm install @chalu/n-tuple-array ``` ```javascript import { tuplesFromArray } from 'n-tuple-array'; +// some setup const numbers = Array.from({length: 100}, (_, i) => i + 1); const isEven = (item) => { if ( @@ -73,8 +74,14 @@ const isEven = (item) => { return true; }; -for (const triplets of tuplesFromArray({list: numbers, maxItems: 3, match: isEven})) { - console.log(triplets); +// use the lib +const quintetIterator = tuplesFromArray({ + list: numbers, maxItems: 5, match: isEven +}); + +for (const quintet of quintetIterator) { + // prints [ 2, 4, 6, 8, 10 ] ... [ 92, 94, 96, 98, 100 ] + console.log(quintet); } ``` diff --git a/package.json b/package.json index d98121b..aa2d186 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "n-tuple-array", + "name": "@chalu/n-tuple-array", "version": "0.1", "description": "Get a specified amount of items when iterating over a JavaScript array, instead of just a single item that native arrays provide!", "main": "dist/index.js", @@ -11,8 +11,8 @@ "build": "tsc", "prebuild": "rm -rf dist/*", "postbuild": "rm -rf dist/demo/*.d.*", - "lint": "xo", - "lint:fix": "xo --fix", + "lint": "xo $(git diff --name-only --diff-filter=d HEAD | grep -E '\\.(ts|js)$' | xargs)", + "lint:fix": "xo --fix $(git diff --name-only --diff-filter=d HEAD | grep -E '\\.(ts|js)$' | xargs)", "test": "jest --runInBand", "pretest": "pnpm lint && pnpm build", "test:ci": "jest --ci --config='./jest.config.ci.ts'",