Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coleccionista

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coleccionista - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

LICENSE

41

index.js
"use strict";
var inherits = require("util").inherits;
var fs = require("fs");
let path = require("path");
var PassThrough = require("stream").PassThrough;
var inherits = require("util").inherits;
var glob = require("glob");
var isArray = Array.isArray;
var Coleccionista = function(filesOrStreams, options) {
if(!filesOrStreams.length) {
throw new Error("Files argument required");
}
var mapFiles = function (srcPath, files) {
return files.map(function(filePath){
return path.join(srcPath, filePath);
});
};
var Coleccionista = function(options, cb) {
let self = this;
PassThrough.call(this, options);
this.files = filesOrStreams;
this.fileIndex = 0;
this.o = options;
this.next();
this.o = options.stream;
if(typeof options.files === "string") {
glob(options.files, {cwd: options.path}, function(err, files) {
if(err) {
cb(err);
} if(!files.length) {
cb(new Error(options.path ? ("No files found in path " + options.path) : "No files found"));
} else {
self.files = files;
cb(null, files);
self.next();
}
});
} else if(isArray(options.files)) {
this.files = options.path ? mapFiles(options.path, options.files) : options.files;
cb(null, this.files);
self.next();
} else {
throw new Error("Files option required");
}
};

@@ -18,0 +43,0 @@ inherits(Coleccionista, PassThrough);

38

package.json
{
"name": "coleccionista",
"version": "0.0.3",
"description": "Helper class that streams files one by one.",
"keywords": ["stream", "files", "collect"],
"author": "Alexey Novikov (http://2dubs.com)",
"preferGlobal": true,
"private": false,
"engines": {
"node": "~0.10.0"
},
"repository": {
"type": "git",
"url": "git@github.com:velocityzen/coleccionista.git"
},
"main": ".index"
"name": "coleccionista",
"version": "0.1.0",
"description": "Helper class that streams files one by one.",
"keywords": [
"stream",
"files",
"collect"
],
"author": "Alexey Novikov (http://2dubs.com)",
"preferGlobal": true,
"private": false,
"engines": {
"node": "^0.10.0",
"iojs": "^1.0.0"
},
"repository": {
"type": "git",
"url": "git@github.com:velocityzen/coleccionista.git"
},
"main": ".index",
"dependencies": {
"glob": "^5.0.3"
}
}
# Coleccionista #
Helper stream class that streams files or other streams one by one in one stream.
Streams files or other streams one by one in one stream.
### Usage ###
```js
var Coleccionista = require('coleccionista');
let Coleccionista = require('coleccionista');
var stream = new Coleccionista(filesOrStreams, options);
//filesOrStreams — array of pathes to files or array of streams
//options — options for file streams
let stream = new Coleccionista(options, function(err, files) {
//err — if no files found or some other fs error
//files — array of full file pathes
});

@@ -18,5 +19,10 @@ // now we can use it like usual stream

### options
* **files** — array of files or wildcard string. For more info look [minimatch documentation](https://github.com/isaacs/minimatch)
* **path** — optional, path to look for a files
* **stream** — optional, read files stream options
### Additional events ###
* __itemstart__ — triggers when new file open
* __itemend__ — triggers when file stream end
* __itemstart__ — triggers when new file begins
* __itemend__ — triggers when file stream ended
* __error__ — triggers on file errors

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc