├── .gitignore ├── test ├── fixtures │ ├── file.txt │ ├── dir │ │ └── file2.txt │ └── empty.car └── test.spec.js ├── src ├── index.browser.js └── index.js ├── tsconfig.json ├── package.json ├── .github └── workflows │ └── main.yml ├── README.md ├── CHANGELOG.md └── LICENSE.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | types 3 | -------------------------------------------------------------------------------- /test/fixtures/file.txt: -------------------------------------------------------------------------------- 1 | Hello World! 😎 -------------------------------------------------------------------------------- /test/fixtures/dir/file2.txt: -------------------------------------------------------------------------------- 1 | Hello World 2! 😎 -------------------------------------------------------------------------------- /test/fixtures/empty.car: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/storacha/files-from-path/HEAD/test/fixtures/empty.car -------------------------------------------------------------------------------- /src/index.browser.js: -------------------------------------------------------------------------------- 1 | export async function filesFromPaths () { 2 | throw new Error('Unsupported in this environment') 3 | } 4 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowJs": true, 4 | "checkJs": true, 5 | "forceConsistentCasingInFileNames": true, 6 | "noImplicitReturns": false, 7 | "noImplicitAny": true, 8 | "noImplicitThis": true, 9 | "noFallthroughCasesInSwitch": true, 10 | "noUnusedLocals": true, 11 | "noUnusedParameters": true, 12 | "strictFunctionTypes": false, 13 | "strictNullChecks": true, 14 | "strictPropertyInitialization": true, 15 | "strictBindCallApply": true, 16 | "strict": true, 17 | "alwaysStrict": true, 18 | "esModuleInterop": true, 19 | "target": "ESNext", 20 | "module": "ESNext", 21 | "moduleResolution": "node", 22 | "declaration": true, 23 | "declarationMap": true, 24 | "outDir": "types", 25 | "skipLibCheck": true, 26 | "stripInternal": true, 27 | "resolveJsonModule": true, 28 | "emitDeclarationOnly": true, 29 | "baseUrl": ".", 30 | }, 31 | "include": [ 32 | "src" 33 | ], 34 | "exclude": [ 35 | "node_modules", 36 | "cjs", 37 | "esm", 38 | "test" 39 | ], 40 | "compileOnSave": false 41 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "files-from-path", 3 | "version": "1.1.4", 4 | "description": "Expand paths to file-like objects with name, readable stream and size.", 5 | "main": "src/index.js", 6 | "types": "./types/index.d.ts", 7 | "type": "module", 8 | "author": "vasco-santos", 9 | "license": "Apache-2.0 OR MIT", 10 | "scripts": { 11 | "build": "tsc --build", 12 | "test": "ava --verbose test/test.spec.js --timeout 30s", 13 | "lint": "standard" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/storacha/files-from-path.git" 18 | }, 19 | "standard": { 20 | "ignore": [ 21 | "dist" 22 | ] 23 | }, 24 | "files": [ 25 | "src", 26 | "types" 27 | ], 28 | "exports": { 29 | ".": { 30 | "browser": "./src/index.browser.js", 31 | "import": "./src/index.js", 32 | "types": "./types/index.d.ts" 33 | } 34 | }, 35 | "dependencies": { 36 | "graceful-fs": "^4.2.10" 37 | }, 38 | "devDependencies": { 39 | "@types/graceful-fs": "^4.1.6", 40 | "@types/node": "^20.9.0", 41 | "ava": "^6.2.0", 42 | "standard": "^17.0.0", 43 | "typescript": "^5.2.2", 44 | "unlimited": "^1.2.2" 45 | }, 46 | "engines": { 47 | "node": ">=18" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: 7 | branches: 8 | - '**' 9 | 10 | jobs: 11 | check: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | - uses: actions/setup-node@v4 16 | with: 17 | node-version: 22 18 | cache: 'npm' 19 | - run: npm ci 20 | - run: npm run lint 21 | 22 | test: 23 | runs-on: ${{ matrix.os }} 24 | strategy: 25 | fail-fast: false 26 | matrix: 27 | os: [ubuntu-latest, macos-latest, windows-latest] 28 | node: [20, 22] 29 | steps: 30 | - uses: actions/checkout@v4 31 | - uses: actions/setup-node@v4 32 | with: 33 | node-version: ${{matrix.node}} 34 | - run: npm ci 35 | - run: npm run test 36 | 37 | release: 38 | if: (github.event_name == 'push' && github.ref == 'refs/heads/main') 39 | needs: 40 | - test 41 | - check 42 | runs-on: ubuntu-latest 43 | permissions: 44 | id-token: write 45 | contents: write 46 | pull-requests: write 47 | steps: 48 | - uses: actions/checkout@v4 49 | - uses: googleapis/release-please-action@v4 50 | id: release 51 | with: 52 | release-type: node 53 | package-name: files-from-path 54 | changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Other Changes","hidden":false}]' 55 | - uses: actions/setup-node@v4 56 | if: ${{ steps.release.outputs.release_created }} 57 | with: 58 | node-version: 22 59 | cache: 'npm' 60 | registry-url: 'https://registry.npmjs.org' 61 | - run: npm ci 62 | if: ${{ steps.release.outputs.release_created }} 63 | - run: npm run build 64 | if: ${{ steps.release.outputs.release_created }} 65 | - run: npm publish --provenance 66 | if: ${{ steps.release.outputs.release_created }} 67 | env: 68 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 69 | 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # files-from-path 2 | 3 | > Expand paths to file-like objects with name, readable stream and size. 4 | 5 | [![Build](https://github.com/storacha/files-from-path/actions/workflows/main.yml/badge.svg)](https://github.com/storacha/files-from-path/actions/workflows/main.yml) 6 | [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) 7 | [![Downloads](https://img.shields.io/npm/dm/files-from-path.svg)](https://www.npmjs.com/package/files-from-path) 8 | 9 | ## Install 10 | 11 | ```sh 12 | npm install files-from-path 13 | ``` 14 | 15 | ## Usage 16 | 17 | ```js 18 | import { filesFromPaths } from 'files-from-path' 19 | 20 | // Given a file system like: 21 | // path/to/file.txt 22 | // path/to/dir/a.pdf 23 | // path/to/dir/images/cat.gif 24 | 25 | const files = await filesFromPaths(['path/to/file.txt', 'path/to/dir']) 26 | console.log(files) 27 | 28 | // Output: 29 | // [ 30 | // { name: 'file.txt', stream: [Function: stream] }, 31 | // { name: 'dir/b.pdf', stream: [Function: stream] }, 32 | // { name: 'dir/images/cat.gif', stream: [Function: stream] }, 33 | // ] 34 | // Note: common sub-path ("path/to/") is removed. 35 | ``` 36 | 37 | ## API 38 | 39 | ### `filesFromPaths` 40 | 41 | The following parameters can be provided to `filesFromPaths`: 42 | 43 | | Name | Type | Description | 44 | |------|------|-------------| 45 | | paths | `Iterable` | File system path(s) to read from | 46 | | [options] | `object` | options | 47 | | [options.hidden] | `boolean` | Include .dot files in matched paths (default: `false`) | 48 | | [options.sort] | `boolean` | Sort files by path (default: `true`) | 49 | 50 | It returns an _array_ of file-like objects in the form: 51 | 52 | ```ts 53 | { 54 | name: string 55 | stream: () => ReadableStream 56 | size: number 57 | } 58 | ``` 59 | 60 | ## Releasing 61 | 62 | Releasing to npm is done via [`release-please`](https://github.com/googleapis/release-please). A Release PR will be opened with a CHANGELOG update in after a PR is merged to main. Merging the release PR will publish the new version to npm. 63 | 64 | ## Contributing 65 | 66 | Feel free to join in. All welcome. Please [open an issue](https://github.com/storacha/files-from-path/issues)! 67 | 68 | ## License 69 | 70 | Dual-licensed under [Apache 2.0 OR MIT](https://github.com/storacha/files-from-path/blob/main/LICENSE.md) 71 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [1.1.4](https://github.com/storacha/files-from-path/compare/v1.1.3...v1.1.4) (2025-03-25) 4 | 5 | 6 | ### Bug Fixes 7 | 8 | * build ([448b532](https://github.com/storacha/files-from-path/commit/448b532316a881ef219a44741152e1883ce692fa)) 9 | 10 | ## [1.1.3](https://github.com/storacha/files-from-path/compare/v1.1.2...v1.1.3) (2025-02-12) 11 | 12 | 13 | ### Bug Fixes 14 | 15 | * github URLs ([51f7007](https://github.com/storacha/files-from-path/commit/51f7007fdad3685cd28e36b8a1242294415c2915)) 16 | 17 | ## [1.1.2](https://github.com/storacha/files-from-path/compare/v1.1.1...v1.1.2) (2025-02-11) 18 | 19 | 20 | ### Bug Fixes 21 | 22 | * Add missing `types` key to package entry point ([#41](https://github.com/storacha/files-from-path/issues/41)) ([b645e00](https://github.com/storacha/files-from-path/commit/b645e005503e8d55e94b6f97e689e32415b0e2bc)) 23 | 24 | ## [1.1.1](https://github.com/storacha/files-from-path/compare/v1.1.0...v1.1.1) (2024-11-15) 25 | 26 | 27 | ### Bug Fixes 28 | 29 | * docs ([ac4fb2d](https://github.com/storacha/files-from-path/commit/ac4fb2da2178eddcf6ce613a57a91990d347c3e9)) 30 | 31 | ## [1.1.0](https://github.com/storacha/files-from-path/compare/v1.0.4...v1.1.0) (2024-11-15) 32 | 33 | 34 | ### Features 35 | 36 | * normalise paths for windows file paths ([#38](https://github.com/storacha/files-from-path/issues/38)) ([41bb5c5](https://github.com/storacha/files-from-path/commit/41bb5c5221bea361aaec1a542c10b8d80658d907)) 37 | 38 | ## [1.0.4](https://github.com/web3-storage/files-from-path/compare/v1.0.3...v1.0.4) (2023-12-07) 39 | 40 | 41 | ### Bug Fixes 42 | 43 | * build step cannot be run in dist dir ([198359f](https://github.com/web3-storage/files-from-path/commit/198359f2b66cfecfe30997560456972fa422fd81)) 44 | 45 | ## [1.0.3](https://github.com/web3-storage/files-from-path/compare/v1.0.2...v1.0.3) (2023-11-29) 46 | 47 | 48 | ### Bug Fixes 49 | 50 | * publish from dist ([#33](https://github.com/web3-storage/files-from-path/issues/33)) ([fea9816](https://github.com/web3-storage/files-from-path/commit/fea981658901412865df00971e9cd3d68904eb88)) 51 | 52 | ## [1.0.2](https://github.com/web3-storage/files-from-path/compare/v1.0.1...v1.0.2) (2023-11-20) 53 | 54 | 55 | ### Bug Fixes 56 | 57 | * handle paths as string param ([#29](https://github.com/web3-storage/files-from-path/issues/29)) ([fa7dcf0](https://github.com/web3-storage/files-from-path/commit/fa7dcf0794146c8e747454cf8464c8323b76ec77)) 58 | * https://github.com/web3-storage/files-from-path/issues/28 ([fa7dcf0](https://github.com/web3-storage/files-from-path/commit/fa7dcf0794146c8e747454cf8464c8323b76ec77)) 59 | 60 | 61 | ### Other Changes 62 | 63 | * allow release-plz to open changelog PRs ([#31](https://github.com/web3-storage/files-from-path/issues/31)) ([350c916](https://github.com/web3-storage/files-from-path/commit/350c916ac478fb64df7aadacb0795450aca2b5db)) 64 | * release from ci and add `--provenance` for verifiable builds! ([#30](https://github.com/web3-storage/files-from-path/issues/30)) ([7ae47f4](https://github.com/web3-storage/files-from-path/commit/7ae47f44f2e3e3b649273646ef74cad1bdc475c3)) 65 | -------------------------------------------------------------------------------- /test/test.spec.js: -------------------------------------------------------------------------------- 1 | /* global WritableStream */ 2 | import test from 'ava' 3 | import Path from 'path' 4 | import process from 'process' 5 | import os from 'os' 6 | import fs from 'fs' 7 | import unlimited from 'unlimited' 8 | import { filesFromPaths } from '../src/index.js' 9 | 10 | test('gets files from path string ', async (t) => { 11 | const files = await filesFromPaths('test/fixtures/dir') 12 | t.is(files.length, 1) 13 | }) 14 | 15 | test('gets files from path array', async (t) => { 16 | const files = await filesFromPaths(['test/fixtures/dir']) 17 | t.is(files.length, 1) 18 | }) 19 | 20 | test('includes file size', async (t) => { 21 | const files = await filesFromPaths(['test/fixtures/empty.car']) 22 | t.is(files.length, 1) 23 | t.is(files[0].size, 18) 24 | }) 25 | 26 | test('removes common path prefix', async (t) => { 27 | const files = await filesFromPaths(['test/fixtures/dir/file2.txt', './test/fixtures/empty.car']) 28 | t.true(files.length > 1) 29 | for (const file of files) { 30 | t.false(file.name.startsWith('test/fixtures/')) 31 | } 32 | }) 33 | 34 | test('single file has name', async (t) => { 35 | const files = await filesFromPaths(['test/fixtures/empty.car']) 36 | t.is(files.length, 1) 37 | t.is(files[0].name, 'empty.car') 38 | }) 39 | 40 | test('gets files from fixtures folder', async t => { 41 | const files = await filesFromPaths([`${process.cwd()}/test/fixtures`]) 42 | t.true(files.length === 3) 43 | }) 44 | 45 | test('allows read of more files than ulimit maxfiles', async t => { 46 | const totalFiles = 256 47 | const dir = await generateTestData(totalFiles) 48 | 49 | try { 50 | const files = await filesFromPaths([dir]) 51 | t.is(files.length, totalFiles) 52 | 53 | // Restrict open files to less than the total files we'll read. 54 | unlimited(totalFiles - 1) 55 | 56 | // Make sure we can read ALL of these files at the same time. 57 | await t.notThrowsAsync(() => Promise.all(files.map(async f => { 58 | await f.stream().pipeTo(new WritableStream({ 59 | async write () { 60 | // make slow so we open all the files 61 | await new Promise(resolve => setTimeout(resolve, 5000)) 62 | } 63 | })) 64 | }))) 65 | } finally { 66 | await fs.promises.rm(dir, { recursive: true, force: true }) 67 | } 68 | }) 69 | 70 | test('uses custom fs implementation', async t => { 71 | // it uses graceful-fs by default so passing node:fs is legit test 72 | const files = await filesFromPaths([`${process.cwd()}/test/fixtures`], { fs }) 73 | t.true(files.length === 3) 74 | }) 75 | 76 | test('sorts by path', async t => { 77 | const paths = ['dir/file2.txt', 'empty.car', 'file.txt'] 78 | /** @param {string} name */ 79 | const toDirEnt = name => ({ name, isFile: () => true, isDirectory: () => false }) 80 | const files = await filesFromPaths([`${process.cwd()}/test/fixtures`], { 81 | fs: { 82 | createReadStream: fs.createReadStream, 83 | promises: { 84 | stat: fs.promises.stat, 85 | readdir: async () => [...paths].reverse().map(toDirEnt) 86 | } 87 | } 88 | }) 89 | t.deepEqual(files.map(f => f.name), paths) 90 | }) 91 | 92 | /** 93 | * @param {number} n 94 | */ 95 | async function generateTestData (n) { 96 | const dirName = Path.join(os.tmpdir(), `files-from-path-test-${Date.now()}`) 97 | await fs.promises.mkdir(dirName) 98 | for (let i = 0; i < n; i++) { 99 | await fs.promises.writeFile(Path.join(dirName, `${i}.json`), '{}') 100 | } 101 | return dirName 102 | } 103 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import gracefulfs from 'graceful-fs' 2 | import { promisify } from 'util' 3 | import path from 'path' 4 | import { Readable } from 'stream' 5 | 6 | /** 7 | * @typedef {Pick} FileLike 8 | * @typedef {{ 9 | * name: string 10 | * isFile: () => boolean 11 | * isDirectory: () => boolean 12 | * }} Dirent 13 | * @typedef {{ 14 | * readdir: (path: string, options: { withFileTypes: true }) => Promise 15 | * }} DirReader 16 | * @typedef {{ 17 | * size: number 18 | * isFile: () => boolean 19 | * isDirectory: () => boolean 20 | * }} Stats 21 | * @typedef {{ stat: (path: string) => Promise }} StatGetter 22 | * @typedef {{ 23 | * createReadStream: (path: string) => import('node:fs').ReadStream 24 | * promises: DirReader & StatGetter 25 | * }} FileSystem 26 | */ 27 | 28 | const defaultfs = { 29 | createReadStream: gracefulfs.createReadStream, 30 | promises: { 31 | // https://github.com/isaacs/node-graceful-fs/issues/160 32 | stat: promisify(gracefulfs.stat), 33 | readdir: promisify(gracefulfs.readdir) 34 | } 35 | } 36 | 37 | /** 38 | * @param {string | Iterable} paths 39 | * @param {object} [options] 40 | * @param {boolean} [options.hidden] 41 | * @param {boolean} [options.sort] Sort by path. Default: true. 42 | * @param {FileSystem} [options.fs] Custom FileSystem implementation. 43 | * @returns {Promise} 44 | */ 45 | export async function filesFromPaths (paths, options) { 46 | if (typeof paths === 'string') { 47 | paths = [paths] 48 | } 49 | /** @type {string[]|undefined} */ 50 | let commonParts 51 | const files = [] 52 | for (const p of paths) { 53 | for await (const file of filesFromPath(p, options)) { 54 | files.push(file) 55 | const nameParts = file.name.split(path.sep) 56 | if (commonParts == null) { 57 | commonParts = nameParts.slice(0, -1) 58 | continue 59 | } 60 | for (let i = 0; i < commonParts.length; i++) { 61 | if (commonParts[i] !== nameParts[i]) { 62 | commonParts = commonParts.slice(0, i) 63 | break 64 | } 65 | } 66 | } 67 | } 68 | const commonPath = `${(commonParts ?? []).join('/')}/` 69 | const commonPathFiles = files.map(f => ({ 70 | ...f, 71 | // normalize file path on windows 72 | name: path.sep === '\\' 73 | ? f.name.split(path.sep).join('/').slice(commonPath.length) 74 | : f.name.slice(commonPath.length) 75 | })) 76 | return options?.sort == null || options?.sort === true 77 | ? commonPathFiles.sort((a, b) => a.name === b.name ? 0 : a.name > b.name ? 1 : -1) 78 | : commonPathFiles 79 | } 80 | 81 | /** 82 | * @param {string} filepath 83 | * @param {object} [options] 84 | * @param {boolean} [options.hidden] 85 | * @param {FileSystem} [options.fs] Custom FileSystem implementation. 86 | * @returns {AsyncIterableIterator} 87 | */ 88 | async function * filesFromPath (filepath, options) { 89 | filepath = path.resolve(filepath) 90 | const fs = options?.fs ?? defaultfs 91 | const hidden = options?.hidden ?? false 92 | 93 | /** @param {string} filepath */ 94 | const filter = filepath => { 95 | if (!hidden && path.basename(filepath).startsWith('.')) return false 96 | return true 97 | } 98 | 99 | const name = filepath 100 | const stat = await fs.promises.stat(name) 101 | 102 | if (!filter(name)) { 103 | return 104 | } 105 | 106 | if (stat.isFile()) { 107 | // @ts-expect-error node web stream not type compatible with web stream 108 | yield { name, stream: () => Readable.toWeb(fs.createReadStream(name)), size: stat.size } 109 | } else if (stat.isDirectory()) { 110 | yield * filesFromDir(name, filter, options) 111 | } 112 | } 113 | 114 | /** 115 | * @param {string} dir 116 | * @param {(name: string) => boolean} filter 117 | * @param {object} [options] 118 | * @param {FileSystem} [options.fs] Custom FileSystem implementation. 119 | * @returns {AsyncIterableIterator} 120 | */ 121 | async function * filesFromDir (dir, filter, options) { 122 | const fs = options?.fs ?? defaultfs 123 | const entries = await fs.promises.readdir(path.join(dir), { withFileTypes: true }) 124 | for (const entry of entries) { 125 | if (!filter(entry.name)) { 126 | continue 127 | } 128 | 129 | if (entry.isFile()) { 130 | const name = path.join(dir, entry.name) 131 | const { size } = await fs.promises.stat(name) 132 | // @ts-expect-error node web stream not type compatible with web stream 133 | yield { name, stream: () => Readable.toWeb(fs.createReadStream(name)), size } 134 | } else if (entry.isDirectory()) { 135 | yield * filesFromDir(path.join(dir, entry.name), filter) 136 | } 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The contents of this repository are Copyright (c) corresponding authors and 2 | contributors, licensed under the `Permissive License Stack` meaning either of: 3 | 4 | - Apache-2.0 Software License: https://www.apache.org/licenses/LICENSE-2.0 5 | ([...4tr2kfsq](https://dweb.link/ipfs/bafkreiankqxazcae4onkp436wag2lj3ccso4nawxqkkfckd6cg4tr2kfsq)) 6 | 7 | - MIT Software License: https://opensource.org/licenses/MIT 8 | ([...vljevcba](https://dweb.link/ipfs/bafkreiepofszg4gfe2gzuhojmksgemsub2h4uy2gewdnr35kswvljevcba)) 9 | 10 | You may not use the contents of this repository except in compliance 11 | with one of the listed Licenses. For an extended clarification of the 12 | intent behind the choice of Licensing please refer to 13 | https://protocol.ai/blog/announcing-the-permissive-license-stack/ 14 | 15 | Unless required by applicable law or agreed to in writing, software 16 | distributed under the terms listed in this notice is distributed on 17 | an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 18 | either express or implied. See each License for the specific language 19 | governing permissions and limitations under that License. 20 | 21 | 22 | 23 | `SPDX-License-Identifier: Apache-2.0 OR MIT` 24 | 25 | Verbatim copies of both licenses are included below: 26 | 27 |
Apache-2.0 Software License 28 | 29 | ``` 30 | Apache License 31 | Version 2.0, January 2004 32 | http://www.apache.org/licenses/ 33 | 34 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 35 | 36 | 1. Definitions. 37 | 38 | "License" shall mean the terms and conditions for use, reproduction, 39 | and distribution as defined by Sections 1 through 9 of this document. 40 | 41 | "Licensor" shall mean the copyright owner or entity authorized by 42 | the copyright owner that is granting the License. 43 | 44 | "Legal Entity" shall mean the union of the acting entity and all 45 | other entities that control, are controlled by, or are under common 46 | control with that entity. For the purposes of this definition, 47 | "control" means (i) the power, direct or indirect, to cause the 48 | direction or management of such entity, whether by contract or 49 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 50 | outstanding shares, or (iii) beneficial ownership of such entity. 51 | 52 | "You" (or "Your") shall mean an individual or Legal Entity 53 | exercising permissions granted by this License. 54 | 55 | "Source" form shall mean the preferred form for making modifications, 56 | including but not limited to software source code, documentation 57 | source, and configuration files. 58 | 59 | "Object" form shall mean any form resulting from mechanical 60 | transformation or translation of a Source form, including but 61 | not limited to compiled object code, generated documentation, 62 | and conversions to other media types. 63 | 64 | "Work" shall mean the work of authorship, whether in Source or 65 | Object form, made available under the License, as indicated by a 66 | copyright notice that is included in or attached to the work 67 | (an example is provided in the Appendix below). 68 | 69 | "Derivative Works" shall mean any work, whether in Source or Object 70 | form, that is based on (or derived from) the Work and for which the 71 | editorial revisions, annotations, elaborations, or other modifications 72 | represent, as a whole, an original work of authorship. For the purposes 73 | of this License, Derivative Works shall not include works that remain 74 | separable from, or merely link (or bind by name) to the interfaces of, 75 | the Work and Derivative Works thereof. 76 | 77 | "Contribution" shall mean any work of authorship, including 78 | the original version of the Work and any modifications or additions 79 | to that Work or Derivative Works thereof, that is intentionally 80 | submitted to Licensor for inclusion in the Work by the copyright owner 81 | or by an individual or Legal Entity authorized to submit on behalf of 82 | the copyright owner. For the purposes of this definition, "submitted" 83 | means any form of electronic, verbal, or written communication sent 84 | to the Licensor or its representatives, including but not limited to 85 | communication on electronic mailing lists, source code control systems, 86 | and issue tracking systems that are managed by, or on behalf of, the 87 | Licensor for the purpose of discussing and improving the Work, but 88 | excluding communication that is conspicuously marked or otherwise 89 | designated in writing by the copyright owner as "Not a Contribution." 90 | 91 | "Contributor" shall mean Licensor and any individual or Legal Entity 92 | on behalf of whom a Contribution has been received by Licensor and 93 | subsequently incorporated within the Work. 94 | 95 | 2. Grant of Copyright License. Subject to the terms and conditions of 96 | this License, each Contributor hereby grants to You a perpetual, 97 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 98 | copyright license to reproduce, prepare Derivative Works of, 99 | publicly display, publicly perform, sublicense, and distribute the 100 | Work and such Derivative Works in Source or Object form. 101 | 102 | 3. Grant of Patent License. Subject to the terms and conditions of 103 | this License, each Contributor hereby grants to You a perpetual, 104 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 105 | (except as stated in this section) patent license to make, have made, 106 | use, offer to sell, sell, import, and otherwise transfer the Work, 107 | where such license applies only to those patent claims licensable 108 | by such Contributor that are necessarily infringed by their 109 | Contribution(s) alone or by combination of their Contribution(s) 110 | with the Work to which such Contribution(s) was submitted. If You 111 | institute patent litigation against any entity (including a 112 | cross-claim or counterclaim in a lawsuit) alleging that the Work 113 | or a Contribution incorporated within the Work constitutes direct 114 | or contributory patent infringement, then any patent licenses 115 | granted to You under this License for that Work shall terminate 116 | as of the date such litigation is filed. 117 | 118 | 4. Redistribution. You may reproduce and distribute copies of the 119 | Work or Derivative Works thereof in any medium, with or without 120 | modifications, and in Source or Object form, provided that You 121 | meet the following conditions: 122 | 123 | (a) You must give any other recipients of the Work or 124 | Derivative Works a copy of this License; and 125 | 126 | (b) You must cause any modified files to carry prominent notices 127 | stating that You changed the files; and 128 | 129 | (c) You must retain, in the Source form of any Derivative Works 130 | that You distribute, all copyright, patent, trademark, and 131 | attribution notices from the Source form of the Work, 132 | excluding those notices that do not pertain to any part of 133 | the Derivative Works; and 134 | 135 | (d) If the Work includes a "NOTICE" text file as part of its 136 | distribution, then any Derivative Works that You distribute must 137 | include a readable copy of the attribution notices contained 138 | within such NOTICE file, excluding those notices that do not 139 | pertain to any part of the Derivative Works, in at least one 140 | of the following places: within a NOTICE text file distributed 141 | as part of the Derivative Works; within the Source form or 142 | documentation, if provided along with the Derivative Works; or, 143 | within a display generated by the Derivative Works, if and 144 | wherever such third-party notices normally appear. The contents 145 | of the NOTICE file are for informational purposes only and 146 | do not modify the License. You may add Your own attribution 147 | notices within Derivative Works that You distribute, alongside 148 | or as an addendum to the NOTICE text from the Work, provided 149 | that such additional attribution notices cannot be construed 150 | as modifying the License. 151 | 152 | You may add Your own copyright statement to Your modifications and 153 | may provide additional or different license terms and conditions 154 | for use, reproduction, or distribution of Your modifications, or 155 | for any such Derivative Works as a whole, provided Your use, 156 | reproduction, and distribution of the Work otherwise complies with 157 | the conditions stated in this License. 158 | 159 | 5. Submission of Contributions. Unless You explicitly state otherwise, 160 | any Contribution intentionally submitted for inclusion in the Work 161 | by You to the Licensor shall be under the terms and conditions of 162 | this License, without any additional terms or conditions. 163 | Notwithstanding the above, nothing herein shall supersede or modify 164 | the terms of any separate license agreement you may have executed 165 | with Licensor regarding such Contributions. 166 | 167 | 6. Trademarks. This License does not grant permission to use the trade 168 | names, trademarks, service marks, or product names of the Licensor, 169 | except as required for reasonable and customary use in describing the 170 | origin of the Work and reproducing the content of the NOTICE file. 171 | 172 | 7. Disclaimer of Warranty. Unless required by applicable law or 173 | agreed to in writing, Licensor provides the Work (and each 174 | Contributor provides its Contributions) on an "AS IS" BASIS, 175 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 176 | implied, including, without limitation, any warranties or conditions 177 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 178 | PARTICULAR PURPOSE. You are solely responsible for determining the 179 | appropriateness of using or redistributing the Work and assume any 180 | risks associated with Your exercise of permissions under this License. 181 | 182 | 8. Limitation of Liability. In no event and under no legal theory, 183 | whether in tort (including negligence), contract, or otherwise, 184 | unless required by applicable law (such as deliberate and grossly 185 | negligent acts) or agreed to in writing, shall any Contributor be 186 | liable to You for damages, including any direct, indirect, special, 187 | incidental, or consequential damages of any character arising as a 188 | result of this License or out of the use or inability to use the 189 | Work (including but not limited to damages for loss of goodwill, 190 | work stoppage, computer failure or malfunction, or any and all 191 | other commercial damages or losses), even if such Contributor 192 | has been advised of the possibility of such damages. 193 | 194 | 9. Accepting Warranty or Additional Liability. While redistributing 195 | the Work or Derivative Works thereof, You may choose to offer, 196 | and charge a fee for, acceptance of support, warranty, indemnity, 197 | or other liability obligations and/or rights consistent with this 198 | License. However, in accepting such obligations, You may act only 199 | on Your own behalf and on Your sole responsibility, not on behalf 200 | of any other Contributor, and only if You agree to indemnify, 201 | defend, and hold each Contributor harmless for any liability 202 | incurred by, or claims asserted against, such Contributor by reason 203 | of your accepting any such warranty or additional liability. 204 | 205 | END OF TERMS AND CONDITIONS 206 | ``` 207 | 208 |
209 | 210 |
MIT Software License 211 | 212 | ``` 213 | Permission is hereby granted, free of charge, to any person obtaining a copy 214 | of this software and associated documentation files (the "Software"), to deal 215 | in the Software without restriction, including without limitation the rights 216 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 217 | copies of the Software, and to permit persons to whom the Software is 218 | furnished to do so, subject to the following conditions: 219 | 220 | The above copyright notice and this permission notice shall be included in 221 | all copies or substantial portions of the Software. 222 | 223 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 224 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 225 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 226 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 227 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 228 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 229 | THE SOFTWARE. 230 | ``` 231 | 232 |
233 | --------------------------------------------------------------------------------