From c714c3d49aafdfb6bcd980bc66c16b10d99f12f0 Mon Sep 17 00:00:00 2001 From: Kenny Daniel Date: Wed, 8 May 2024 21:23:01 -0700 Subject: [PATCH] Initial project skeleton --- .eslintrc.json | 61 ++++++++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 26 +++++++++++++++++ .gitignore | 3 ++ LICENSE | 7 +++++ README.md | 11 ++++++++ package.json | 41 +++++++++++++++++++++++++++ src/index.d.ts | 3 ++ src/index.js | 12 ++++++++ test/package.test.js | 20 +++++++++++++ tsconfig.json | 14 +++++++++ 10 files changed, 198 insertions(+) create mode 100644 .eslintrc.json create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 package.json create mode 100644 src/index.d.ts create mode 100644 src/index.js create mode 100644 test/package.test.js create mode 100644 tsconfig.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..47d9dd2 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,61 @@ +{ + "env": { + "browser": true, + "es2021": true, + "node": true + }, + "extends": [ + "eslint:recommended" + ], + "parserOptions": { + "ecmaVersion": 13, + "sourceType": "module" + }, + "plugins": ["import", "jsdoc"], + "rules": { + "arrow-spacing": "error", + "camelcase": "off", + "comma-spacing": "error", + "comma-dangle": ["error", "always-multiline"], + "eol-last": "error", + "eqeqeq": "error", + "func-style": ["error", "declaration"], + "import/order": [ + "error", + { + "alphabetize": { + "caseInsensitive": true, + "order": "asc" + }, + "groups": [["builtin", "external"], "internal", "parent", "sibling", "index"] + } + ], + "indent": ["error", 2], + "jsdoc/check-param-names": "error", + "jsdoc/check-property-names": "error", + "jsdoc/check-tag-names": "error", + "jsdoc/require-param": "error", + "jsdoc/require-param-type": "error", + "jsdoc/require-returns": "error", + "jsdoc/require-returns-type": "error", + "jsdoc/sort-tags": "error", + "no-constant-condition": "off", + "no-multi-spaces": "error", + "no-trailing-spaces": "error", + "no-var": "error", + "object-curly-spacing": ["error", "always"], + "prefer-const": "error", + "prefer-destructuring": ["warn", {"object": true, "array": false}], + "prefer-promise-reject-errors": "error", + "quotes": ["error", "single"], + "require-await": "warn", + "semi": ["error", "never"], + "sort-imports": ["error", { + "ignoreDeclarationSort": true, + "ignoreMemberSort": false, + "memberSyntaxSortOrder": ["none", "all", "multiple", "single"] + }], + "space-infix-ops": "error" + } + } + \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0ec5c83 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: CI +on: + pull_request: + push: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: npm i + - run: npm run lint + + typecheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: npm i + - run: tsc + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: npm i + - run: npm test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4811400 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +coverage +node_modules +package-lock.json diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5523c36 --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index d442030..d27ceaf 100644 --- a/README.md +++ b/README.md @@ -1 +1,12 @@ # hyparquet decompressors + +This package exports a `compressors` object intended to be passed into [hyparquet](https://github.com/hyparam/hyparquet) in order to support all possible Apache Parquet files. + +## Usage + +```js +import { parquetRead } from 'hyparquet' +import { compressors } from 'hyparquet-compressors' + +parquetRead({ file, compressors }) +``` diff --git a/package.json b/package.json new file mode 100644 index 0000000..cba229e --- /dev/null +++ b/package.json @@ -0,0 +1,41 @@ +{ + "name": "hyparquet-compressors", + "version": "0.1.0", + "description": "hyparquet decompressors", + "keywords": [ + "decompress", + "decompression", + "decompressor", + "hyparquet", + "parquet" + ], + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/hyparam/hyparquet-compressors.git" + }, + "main": "src/index.js", + "type": "module", + "types": "src/index.d.ts", + "scripts": { + "coverage": "vitest run --coverage", + "lint": "eslint .", + "test": "vitest run" + }, + "dependencies": { + "hysnappy": "0.3.1" + }, + "devDependencies": { + "@babel/eslint-parser": "7.24.5", + "@types/node": "20.12.11", + "@types/pako": "2.0.3", + "@vitest/coverage-v8": "1.6.0", + "eslint": "8.57.0", + "eslint-plugin-import": "2.29.1", + "eslint-plugin-jsdoc": "48.2.3", + "hyparquet": "0.9.0", + "pako": "2.1.0", + "typescript": "5.4.5", + "vitest": "1.6.0" + } +} diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 0000000..b28410a --- /dev/null +++ b/src/index.d.ts @@ -0,0 +1,3 @@ +import { Compressors } from 'hyparquet' + +export const compressors: Compressors diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..8aa96c7 --- /dev/null +++ b/src/index.js @@ -0,0 +1,12 @@ +import { snappyUncompressor } from 'hysnappy' +import pako from 'pako' + +/** + * @typedef {import('hyparquet').Compressors} Compressors + */ +export const compressors = { + SNAPPY: snappyUncompressor(), + GZIP: pako.ungzip, + BROTLI: () => new Uint8Array(), // TODO + ZSTD: () => new Uint8Array(), // TODO +} diff --git a/test/package.test.js b/test/package.test.js new file mode 100644 index 0000000..375e3c2 --- /dev/null +++ b/test/package.test.js @@ -0,0 +1,20 @@ +import { describe, expect, it } from 'vitest' +import packageJson from '../package.json' + +describe('package.json', () => { + it('should have the correct name', () => { + expect(packageJson.name).toBe('hyparquet-compressors') + }) + it('should have a valid version', () => { + expect(packageJson.version).toMatch(/^\d+\.\d+\.\d+$/) + }) + it('should have MIT license', () => { + expect(packageJson.license).toBe('MIT') + }) + it('should have precise dependency versions', () => { + const { devDependencies } = packageJson + Object.values(devDependencies).forEach(version => { + expect(version).toMatch(/^\d+\.\d+\.\d+$/) + }) + }) +}) diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..03324cb --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "lib": ["esnext", "dom"], + "module": "nodenext", + "noEmit": true, + "resolveJsonModule": true, + "skipLibCheck": false, + "strict": true, + "target": "esnext" + }, + "include": ["src", "test"] +}