diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..a180e2f --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,29 @@ +# This workflow will do a clean install of node dependencies, 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, 14, 16, 17] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm i + - run: npm run build --if-present + - run: npm test diff --git a/.npmignore b/.npmignore index 1daa55f..c111508 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,3 @@ .eslintrc.js -.travis.yml +.github test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b274776..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: - - node_js -node_js: - - "10" - - "12" - - "14" -jobs: - include: - - stage: lint - script: npm run lint diff --git a/Blob.js b/Blob.js index ebba533..4211534 100644 --- a/Blob.js +++ b/Blob.js @@ -355,7 +355,7 @@ /* Blob constructor */ /********************************************************/ function Blob (chunks, opts) { - chunks = chunks || []; + chunks = chunks ? chunks.slice() : []; opts = opts == null ? {} : opts; for (var i = 0, len = chunks.length; i < len; i++) { var chunk = chunks[i]; diff --git a/CHANGELOG.md b/CHANGELOG.md index ad7b558..b973d27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # `blob-polyfill` CHANGELOG +## v7.0.20220408 +* [Blob.js] Do not modify array that is passed into constructor (@zyrong) +* [.github] Start automated tests on github (@bjornstar) +* [.travis.yml] Remove travis-ci integration (@bjornstar) +* [.npmignore] Ignore .github, remove .travis.yml (@bjornstar) +* [devDependencies] Update test dependencies (@bjornstar) + ## v6.0.20211015 * [Blob.js] Check object class names when determining Object types (@coclauso) * [Blob.js] Reduce redundancies in getting class names and prototype checks (@bjornstar) diff --git a/package.json b/package.json index 0358ab0..6e619c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blob-polyfill", - "version": "6.0.20211015", + "version": "7.0.20220408", "description": "Blob.js implements the W3C Blob interface in browsers that do not natively support it.", "main": "Blob.js", "scripts": { @@ -22,8 +22,8 @@ }, "homepage": "https://github.com/bjornstar/blob-polyfill", "devDependencies": { - "@sindresorhus/is": "^4.0.0", - "eslint": "^7.19.0", - "mocha": "^8.2.1" + "@sindresorhus/is": "^4.6.0", + "eslint": "^8.12.0", + "mocha": "^9.2.2" } } diff --git a/test/index.js b/test/index.js index 7f38e8e..d106de3 100644 --- a/test/index.js +++ b/test/index.js @@ -61,6 +61,13 @@ describe("blob-polyfill", function () { assert.strictEqual(testString, testStringRecovered); }); }); + + it("Does not modify the source array", function () { + var array = ['mutation']; + var clone = array.slice(); + var blob = new Blob(array); + assert.deepStrictEqual(array, clone); + }); }); describe("File", function () {