pax_global_header00006660000000000000000000000064131272611500014510gustar00rootroot0000000000000052 comment=fb8c2e7aa8ce7935a147c08f8fbec66a70d65ef8 remove-bom-stream-1.2.0/000077500000000000000000000000001312726115000150515ustar00rootroot00000000000000remove-bom-stream-1.2.0/.editorconfig000066400000000000000000000003051312726115000175240ustar00rootroot00000000000000# http://editorconfig.org root = true [*] indent_style = space indent_size = 2 charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.md] trim_trailing_whitespace = false remove-bom-stream-1.2.0/.eslintrc000066400000000000000000000000301312726115000166660ustar00rootroot00000000000000{ "extends": "gulp" } remove-bom-stream-1.2.0/.gitignore000066400000000000000000000012541312726115000170430ustar00rootroot00000000000000# Logs logs *.log # Runtime data pids *.pid *.seed # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directory # Commenting this out is preferred by some people, see # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- node_modules # Users Environment Variables .lock-wscript # Garbage files .DS_Store # Generated by integration tests test/fixtures/tmp test/fixtures/out remove-bom-stream-1.2.0/.jscsrc000066400000000000000000000000271312726115000163400ustar00rootroot00000000000000{ "preset": "gulp" } remove-bom-stream-1.2.0/.travis.yml000066400000000000000000000001711312726115000171610ustar00rootroot00000000000000sudo: false language: node_js node_js: - '8' - '6' - '4' - '0.12' - '0.10' after_script: - npm run coveralls remove-bom-stream-1.2.0/LICENSE000066400000000000000000000022141312726115000160550ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2017 Blaine Bublitz , Eric Schoffstall and other contributors 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. remove-bom-stream-1.2.0/README.md000066400000000000000000000034451312726115000163360ustar00rootroot00000000000000

# remove-bom-stream [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url] Remove a UTF8 BOM at the start of the stream. ## Usage ```js var fs = require('fs'); var concat = require('concat-stream'); var removeBOM = require('remove-bom-stream'); fs.createReadStream('utf8-file-with-bom.txt') .pipe(removeBOM()) .pipe(concat(function(result) { // result won't have a BOM })); ``` ## API ### `removeBOM()` Returns a `through2` stream that will remove a BOM, given the data is a UTF8 Buffer with a BOM at the beginning. If the data is not UTF8 or does not have a BOM, the data is not changed and this becomes a normal passthrough stream. ## License MIT [downloads-image]: http://img.shields.io/npm/dm/remove-bom-stream.svg [npm-url]: https://npmjs.com/package/remove-bom-stream [npm-image]: http://img.shields.io/npm/v/remove-bom-stream.svg [travis-url]: https://travis-ci.org/gulpjs/remove-bom-stream [travis-image]: http://img.shields.io/travis/gulpjs/remove-bom-stream.svg?label=travis-ci [appveyor-url]: https://ci.appveyor.com/project/gulpjs/remove-bom-stream [appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/remove-bom-stream.svg?label=appveyor [coveralls-url]: https://coveralls.io/r/gulpjs/remove-bom-stream [coveralls-image]: http://img.shields.io/coveralls/gulpjs/remove-bom-stream/master.svg [gitter-url]: https://gitter.im/gulpjs/gulp [gitter-image]: https://badges.gitter.im/gulpjs/gulp.png remove-bom-stream-1.2.0/appveyor.yml000066400000000000000000000007211312726115000174410ustar00rootroot00000000000000# http://www.appveyor.com/docs/appveyor-yml # http://www.appveyor.com/docs/lang/nodejs-iojs environment: matrix: # node.js - nodejs_version: "0.10" - nodejs_version: "0.12" - nodejs_version: "4" - nodejs_version: "6" - nodejs_version: "8" install: - ps: Install-Product node $env:nodejs_version - npm install test_script: - node --version - npm --version - cmd: npm test build: off # build version format version: "{build}" remove-bom-stream-1.2.0/index.js000066400000000000000000000017601312726115000165220ustar00rootroot00000000000000'use strict'; var through = require('through2'); var removeBom = require('remove-bom-buffer'); var SafeBuffer = require('safe-buffer').Buffer; function removeBomStream() { var completed = false; var buffer = SafeBuffer.alloc(0); return through(onChunk, onFlush); function removeAndCleanup(data) { completed = true; buffer = null; return removeBom(data); } function onChunk(data, enc, cb) { if (completed) { return cb(null, data); } if (data.length >= 7) { return cb(null, removeAndCleanup(data)); } var bufferLength = buffer.length; var chunkLength = data.length; var totalLength = bufferLength + chunkLength; buffer = SafeBuffer.concat([buffer, data], totalLength); if (totalLength >= 7) { return cb(null, removeAndCleanup(buffer)); } cb(); } function onFlush(cb) { if (completed || !buffer) { return cb(); } cb(null, removeAndCleanup(buffer)); } } module.exports = removeBomStream; remove-bom-stream-1.2.0/package.json000066400000000000000000000023041312726115000173360ustar00rootroot00000000000000{ "name": "remove-bom-stream", "version": "1.2.0", "description": "Remove a UTF8 BOM at the start of the stream.", "author": "Gulp Team (http://gulpjs.com/)", "contributors": [ "Blaine Bublitz " ], "repository": "gulpjs/remove-bom-stream", "license": "MIT", "engines": { "node": ">= 0.10" }, "main": "index.js", "files": [ "LICENSE", "index.js" ], "scripts": { "lint": "eslint index.js test/ && jscs index.js test/", "pretest": "npm run lint", "test": "mocha --async-only", "cover": "istanbul cover _mocha", "coveralls": "npm run cover && istanbul-coveralls" }, "dependencies": { "safe-buffer": "^5.1.0", "remove-bom-buffer": "^3.0.0", "through2": "^2.0.3" }, "devDependencies": { "buffer-equal": "^1.0.0", "eslint": "^1.10.3", "eslint-config-gulp": "^2.0.0", "expect": "^1.20.2", "istanbul": "^0.4.3", "istanbul-coveralls": "^1.0.3", "jscs": "^2.4.0", "jscs-preset-gulp": "^1.0.0", "mississippi": "^1.3.0", "mocha": "^3.2.0", "stream-chunker": "^1.2.8" }, "keywords": [ "bom", "remove", "utf8", "streaming", "stream" ] } remove-bom-stream-1.2.0/test/000077500000000000000000000000001312726115000160305ustar00rootroot00000000000000remove-bom-stream-1.2.0/test/.eslintrc000066400000000000000000000000351312726115000176520ustar00rootroot00000000000000{ "extends": "gulp/test" } remove-bom-stream-1.2.0/test/fixtures/000077500000000000000000000000001312726115000177015ustar00rootroot00000000000000remove-bom-stream-1.2.0/test/fixtures/bom-utf16be-short.txt000066400000000000000000000000051312726115000236210ustar00rootroot00000000000000 remove-bom-stream-1.2.0/test/fixtures/bom-utf16be.txt000066400000000000000000000003641312726115000224740ustar00rootroot00000000000000This file is saved as UTF-16-BE. It contains some garbage at the start that looks like a UTF-8-encoded BOM (but isn t). remove-bom-stream-1.2.0/test/fixtures/bom-utf16le.txt000066400000000000000000000003641312726115000225060ustar00rootroot00000000000000This file is saved as UTF-16-LE. It contains some garbage at the start that looks like a UTF-8-encoded BOM (but isn t). remove-bom-stream-1.2.0/test/fixtures/bom-utf8-short.txt000066400000000000000000000000051312726115000232330ustar00rootroot00000000000000T remove-bom-stream-1.2.0/test/fixtures/bom-utf8.txt000066400000000000000000000000561312726115000221040ustar00rootroot00000000000000This file is saved as UTF-8 with BOM. 𝌆 remove-bom-stream-1.2.0/test/fixtures/test.txt000066400000000000000000000000151312726115000214150ustar00rootroot00000000000000Hello World! remove-bom-stream-1.2.0/test/index.js000066400000000000000000000062511312726115000175010ustar00rootroot00000000000000'use strict'; var fs = require('fs'); var path = require('path'); var expect = require('expect'); var miss = require('mississippi'); var isEqual = require('buffer-equal'); var chunker = require('stream-chunker'); var removeBomStream = require('../'); var pipe = miss.pipe; var concat = miss.concat; describe('removeBomStream', function() { it('ignores UTF8 buffer without a BOM', function(done) { var filepath = path.join(__dirname, './fixtures/test.txt'); var expected = fs.readFileSync(filepath); function assert(data) { expect(isEqual(data, expected)).toEqual(true); } pipe([ fs.createReadStream(filepath), removeBomStream(), concat(assert), ], done); }); it('removes the BOM from a UTF8 buffer', function(done) { var filepath = path.join(__dirname, './fixtures/bom-utf8.txt'); var expected = fs.readFileSync(filepath).slice(3); function assert(data) { expect(isEqual(data, expected)).toEqual(true); } pipe([ fs.createReadStream(filepath), removeBomStream(), concat(assert), ], done); }); it('handles small chunks', function(done) { var filepath = path.join(__dirname, './fixtures/bom-utf8.txt'); var expected = fs.readFileSync(filepath).slice(3); function assert(data) { expect(isEqual(data, expected)).toEqual(true); } pipe([ fs.createReadStream(filepath), chunker(1), removeBomStream(), concat(assert), ], done); }); it('removes the BOM from a UTF8 buffer that is shorter than 7 chars', function(done) { var filepath = path.join(__dirname, './fixtures/bom-utf8-short.txt'); var expected = fs.readFileSync(filepath).slice(3); function assert(data) { expect(data.length < 7).toEqual(true); expect(expected.length < 7).toEqual(true); expect(isEqual(data, expected)).toEqual(true); } pipe([ fs.createReadStream(filepath), removeBomStream(), concat(assert), ], done); }); it('does not remove the BOM from a UTF16BE buffer', function(done) { var filepath = path.join(__dirname, './fixtures/bom-utf16be.txt'); var expected = fs.readFileSync(filepath); function assert(data) { expect(isEqual(data, expected)).toEqual(true); } pipe([ fs.createReadStream(filepath), removeBomStream(), concat(assert), ], done); }); it('does not remove the BOM from a UTF16BE buffer that is shorter than 7 chars', function(done) { var filepath = path.join(__dirname, './fixtures/bom-utf16be-short.txt'); var expected = fs.readFileSync(filepath); function assert(data) { expect(isEqual(data, expected)).toEqual(true); } pipe([ fs.createReadStream(filepath), removeBomStream(), concat(assert), ], done); }); it('does not remove the BOM from a UTF16LE buffer', function(done) { var filepath = path.join(__dirname, './fixtures/bom-utf16le.txt'); var expected = fs.readFileSync(filepath); function assert(data) { expect(isEqual(data, expected)).toEqual(true); } pipe([ fs.createReadStream(filepath), removeBomStream(), concat(assert), ], done); }); });