Installations
npm install noms
Developer Guide
Typescript
No
Module System
CommonJS
NPM Version
1.4.3
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
calvinmetcalf
Download Statistics
Total Downloads
236,068,139
Last Day
232,634
Last Week
1,035,821
Last Month
4,617,929
Last Year
58,006,991
GitHub Statistics
10 Stars
1 Commits
1 Forks
3 Watching
1 Branches
1 Contributors
Bundle Size
16.98 kB
Minified
5.06 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.0.0
Package Id
noms@0.0.0
Size
3.52 kB
NPM Version
1.4.3
Publised On
04 Sept 2014
Total Downloads
Cumulative downloads
Total Downloads
236,068,139
Last day
-4.9%
232,634
Compared to previous day
Last week
-16.5%
1,035,821
Compared to previous week
Last month
3.6%
4,617,929
Compared to previous month
Last year
19.8%
58,006,991
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Dev Dependencies
1
noms
create super easy readable-streams filled with yummy data to nom on, inspired by from2 (and a test based on one from there).
1npm install noms
1var noms = require('noms');
Create a quick readable stream
1nom([options], read, [before]);
options is optional and passed to readable stream just like in from2 or through2
read is the main read function, it is similar to the original node streams but size is optional and a callback is passed. It will NOT be called again until the callback is called.
before is called right before the first call to read in order to do setup, it is passed a callback and read will not be called until the callback is called.
like through2 and from2 noms also features
1nom.obj([options], read, [before]);
which is shorthand for creating an object stream and like from2 noms has
1noms.ctor(read, [before]);
which returns a constructor function for use if you're creating a large number of copies of the stream.
example (based on one from from2):
1function fromString(string) { 2 return noms(function(size, next) { 3 // if there's no more content 4 // left in the string, close the stream. 5 if (string.length <= 0) { 6 return this.push(null); 7 } 8 9 // Pull in a new chunk of text, 10 // removing it from the string. 11 var chunk = string.slice(0, size); 12 string = string.slice(size); 13 14 // Emit "chunk" from the stream. 15 next(null, chunk); 16 }) 17}
you can use this.push(foo)
and next(null, foo)
interchangeably, just remember to call next at the end.
1function fromString(string) { 2 return noms(function(size, next) { 3 // if there's no more content 4 // left in the string, close the stream. 5 if (string.length <= 0) { 6 return next(null, null); 7 } 8 9 // Pull in a new chunk of text, 10 // removing it from the string. 11 var chunk = string.slice(0, size); 12 string = string.slice(size); 13 14 // Emit "chunk" from the stream. 15 this.push(chunk); 16 // finish up 17 next(); 18 }) 19}
If you don't care about size you can omit it
1function fromString(sentence) { 2 var strings = sentence.trim().split(/\s+/); 3 var i = -1; 4 var len = strings.length; 5 return noms(function(next) { 6 // if there's no more content 7 // left in the string, close the stream. 8 if (++i < len) { 9 return this.push(strings[i]); 10 } else { 11 return this.push(null); 12 } 13 next(); 14}
You don't have to worry about the response from this.push, as noms will call the function again after you call next until the cache is full.
1var fs = require('fs'); 2var path = require('path'); 3function getFiles(dir) { 4 var stack = [path.resolve(dir)]; 5 return noms(function(next) { 6 if (!stack.length) { 7 //we are done 8 return next(null, null); 9 } 10 var self = this; 11 var current = stack.pop(); 12 fs.readdir(current, function (err, paths) { 13 if (err) { 14 return next(err); 15 } 16 if (!paths.length) { 17 // this directory is empty 18 return next(); 19 } 20 var todo = paths.length; 21 paths.forEach(function (file) { 22 var fullPath = path.join(current, file); 23 fs.stat(fullPath, function (err, stats) { 24 todo--; 25 if (err) { 26 return next(err); 27 } 28 if (stats.isFile()) { 29 //found a file 30 // emit it as data 31 self.push(fullPath); 32 } else if (stats.isDirectory()) { 33 // found another directory 34 // put it into the stack 35 // is depth first, switch this to 36 // a shift to make it breadth first 37 stack.push(fullPath); 38 } 39 if (!todo) { 40 // we've done all the files 41 // would be a lot simpler if I used promises 42 // would that help or hurt the example? 43 next(); 44 } 45 }); 46 }); 47 }); 48 49}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/1 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
2.6
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More