diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..85c4869 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +public/ +pages/ +coverage/ diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..03fbbf8 --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,10 @@ +export interface IErrorFunction { + (err: any): number; +} +export declare class Smartstream { + streamArray: any[]; + errorFunction: IErrorFunction; + constructor(streamArrayArg: any[]); + onError(errorFunctionArg: IErrorFunction): void; + run(): any; +} diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..1c51d85 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,21 @@ +"use strict"; +const plugins = require("./smartstream.plugins"); +class Smartstream { + constructor(streamArrayArg) { + this.streamArray = []; + this.errorFunction = null; + this.streamArray = streamArrayArg; + } + onError(errorFunctionArg) { + this.errorFunction = errorFunctionArg; + } + run() { + let combinedStream = plugins.streamCombiner2.obj(this.streamArray); + if (this.errorFunction !== null) { + combinedStream.on('error', this.errorFunction); + } + return combinedStream; + } +} +exports.Smartstream = Smartstream; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsaURBQWdEO0FBTWhEO0lBR0ksWUFBWSxjQUFxQjtRQUZqQyxnQkFBVyxHQUFHLEVBQUUsQ0FBQTtRQUNoQixrQkFBYSxHQUFtQixJQUFJLENBQUE7UUFFaEMsSUFBSSxDQUFDLFdBQVcsR0FBRyxjQUFjLENBQUE7SUFDckMsQ0FBQztJQUNELE9BQU8sQ0FBQyxnQkFBZ0M7UUFDcEMsSUFBSSxDQUFDLGFBQWEsR0FBRyxnQkFBZ0IsQ0FBQTtJQUN6QyxDQUFDO0lBQ0QsR0FBRztRQUNDLElBQUksY0FBYyxHQUFHLE9BQU8sQ0FBQyxlQUFlLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQTtRQUNsRSxFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsYUFBYSxLQUFLLElBQUksQ0FBQyxDQUFDLENBQUM7WUFDOUIsY0FBYyxDQUFDLEVBQUUsQ0FBQyxPQUFPLEVBQUUsSUFBSSxDQUFDLGFBQWEsQ0FBQyxDQUFBO1FBQ2xELENBQUM7UUFDRCxNQUFNLENBQUMsY0FBYyxDQUFBO0lBQ3pCLENBQUM7Q0FDSjtBQWhCRCxrQ0FnQkMifQ== \ No newline at end of file diff --git a/dist/smartstream.plugins.d.ts b/dist/smartstream.plugins.d.ts new file mode 100644 index 0000000..05c7dd5 --- /dev/null +++ b/dist/smartstream.plugins.d.ts @@ -0,0 +1,3 @@ +import 'typings-global'; +export import q = require('q'); +export declare let streamCombiner2: any; diff --git a/dist/smartstream.plugins.js b/dist/smartstream.plugins.js new file mode 100644 index 0000000..76418df --- /dev/null +++ b/dist/smartstream.plugins.js @@ -0,0 +1,5 @@ +"use strict"; +require("typings-global"); +exports.q = require("q"); +exports.streamCombiner2 = require('stream-combiner2'); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJlYW0ucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyZWFtLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2Qix5QkFBOEI7QUFDbkIsUUFBQSxlQUFlLEdBQUcsT0FBTyxDQUFDLGtCQUFrQixDQUFDLENBQUEifQ== \ No newline at end of file diff --git a/gitlab-ci.yml b/gitlab-ci.yml new file mode 100644 index 0000000..6206855 --- /dev/null +++ b/gitlab-ci.yml @@ -0,0 +1,42 @@ +image: hosttoday/ht-docker-node:npmts +stages: +- test +- release +- page +testLEGACY: + stage: test + script: + - npmci test legacy + tags: + - docker +testLTS: + stage: test + script: + - npmci test lts + tags: + - docker +testSTABLE: + stage: test + script: + - npmci test stable + tags: + - docker +release: + stage: release + script: + - npmci publish + only: + - tags + tags: + - docker +pages: + image: hosttoday/ht-docker-node:npmpage + stage: page + script: + - npmci command npmpage --host gitlab + only: + - tags + artifacts: + expire_in: 1 week + paths: + - public \ No newline at end of file diff --git a/npmextra.json b/npmextra.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/npmextra.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/package.json b/package.json index dc7baa6..42d37d1 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.0.0", "description": "simplifies access to node streams, TypeScript ready!", "main": "dist/index.js", + "typings": "dist/index.d.ts", "scripts": { "test": "(npmts)" }, @@ -15,5 +16,17 @@ "bugs": { "url": "https://gitlab.com/pushrocks/smartstream/issues" }, - "homepage": "https://gitlab.com/pushrocks/smartstream#README" + "homepage": "https://gitlab.com/pushrocks/smartstream#README", + "devDependencies": { + "@types/should": "^8.1.30", + "npmts-g": "^5.2.8", + "should": "^11.1.0", + "typings-test": "^1.0.3" + }, + "dependencies": { + "@types/q": "0.x.x", + "q": "^1.4.1", + "stream-combiner2": "^1.1.1", + "typings-global": "^1.0.14" + } } diff --git a/test/assets/test.md b/test/assets/test.md new file mode 100644 index 0000000..89c1ec3 --- /dev/null +++ b/test/assets/test.md @@ -0,0 +1 @@ +hi.md \ No newline at end of file diff --git a/test/assets/testCopy.md b/test/assets/testCopy.md new file mode 100644 index 0000000..89c1ec3 --- /dev/null +++ b/test/assets/testCopy.md @@ -0,0 +1 @@ +hi.md \ No newline at end of file diff --git a/test/test.d.ts b/test/test.d.ts new file mode 100644 index 0000000..2fd432a --- /dev/null +++ b/test/test.d.ts @@ -0,0 +1 @@ +import 'typings-test'; diff --git a/test/test.js b/test/test.js new file mode 100644 index 0000000..a650a04 --- /dev/null +++ b/test/test.js @@ -0,0 +1,15 @@ +"use strict"; +require("typings-test"); +const fs = require("fs"); +const smartstream = require("../dist/index"); +let testSmartstream; +describe('smartstream', function () { + it('should combine a stream', function () { + testSmartstream = new smartstream.Smartstream([ + fs.createReadStream('./test/assets/test.md'), + fs.createWriteStream('./test/assets/testCopy.md') + ]); + testSmartstream.run(); + }); +}); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQix5QkFBeUI7QUFHekIsNkNBQTRDO0FBRTVDLElBQUksZUFBd0MsQ0FBQTtBQUU1QyxRQUFRLENBQUMsYUFBYSxFQUFFO0lBQ3BCLEVBQUUsQ0FBQyx5QkFBeUIsRUFBRTtRQUMxQixlQUFlLEdBQUcsSUFBSSxXQUFXLENBQUMsV0FBVyxDQUFDO1lBQzFDLEVBQUUsQ0FBQyxnQkFBZ0IsQ0FBQyx1QkFBdUIsQ0FBQztZQUM1QyxFQUFFLENBQUMsaUJBQWlCLENBQUMsMkJBQTJCLENBQUM7U0FDcEQsQ0FBQyxDQUFBO1FBQ0YsZUFBZSxDQUFDLEdBQUcsRUFBRSxDQUFBO0lBQ3pCLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ== \ No newline at end of file diff --git a/test/test.ts b/test/test.ts new file mode 100644 index 0000000..cf3f52f --- /dev/null +++ b/test/test.ts @@ -0,0 +1,17 @@ +import 'typings-test' +import fs = require('fs') +import * as should from 'should' + +import * as smartstream from '../dist/index' + +let testSmartstream: smartstream.Smartstream + +describe('smartstream', function() { + it('should combine a stream', function(){ + testSmartstream = new smartstream.Smartstream([ + fs.createReadStream('./test/assets/test.md'), + fs.createWriteStream('./test/assets/testCopy.md') + ]) + testSmartstream.run() + }) +}) \ No newline at end of file diff --git a/ts/index.ts b/ts/index.ts new file mode 100644 index 0000000..3f20d01 --- /dev/null +++ b/ts/index.ts @@ -0,0 +1,23 @@ +import * as plugins from './smartstream.plugins' + +export interface IErrorFunction { + (err): number +} + +export class Smartstream { + streamArray = [] + errorFunction: IErrorFunction = null + constructor(streamArrayArg: any[]){ + this.streamArray = streamArrayArg + } + onError(errorFunctionArg: IErrorFunction) { + this.errorFunction = errorFunctionArg + } + run() { + let combinedStream = plugins.streamCombiner2.obj(this.streamArray) + if (this.errorFunction !== null) { + combinedStream.on('error', this.errorFunction) + } + return combinedStream + } +} \ No newline at end of file diff --git a/ts/smartstream.plugins.ts b/ts/smartstream.plugins.ts new file mode 100644 index 0000000..1bc0d6f --- /dev/null +++ b/ts/smartstream.plugins.ts @@ -0,0 +1,3 @@ +import 'typings-global' +export import q = require('q') +export let streamCombiner2 = require('stream-combiner2') diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..45052ad --- /dev/null +++ b/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "tslint-config-standard" +}