Comparing version 0.0.13 to 0.0.14
@@ -10,7 +10,11 @@ /** | ||
MongoId: require('./mongoid.js').MongoId, | ||
Fgets: require('./fgets.js'), | ||
FileReader: require('./lib/file-reader.js'), | ||
phpdate: require('./lib/phpdate'), | ||
str_repeat: require('./lib/str_repeat'), | ||
timeit: require('./lib/timeit'), | ||
// pass-through includes from related packages (must be installed separately) | ||
Fgets: require('qfgets'), | ||
FileReader: require('qfgets').FileReader, | ||
Fputs: require('qfputs'), | ||
FileWriter: require('qfputs').FileWriter, | ||
}; |
{ | ||
"name": "arlib", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"description": "Andras' Utility Functions", | ||
@@ -36,3 +36,2 @@ "license": "Apache-2.0", | ||
"mongo", | ||
"fgets", | ||
"phpdate", | ||
@@ -47,3 +46,2 @@ "datetime", | ||
"dependencies": { | ||
"fs-ext": "*" | ||
}, | ||
@@ -50,0 +48,0 @@ "devDependencies": { |
@@ -8,2 +8,5 @@ # arlib | ||
Note: [qfgets](https://www.npmjs.org/package/qfgets) which first appeared here | ||
was moved into its own package. | ||
## Contents | ||
@@ -56,41 +59,2 @@ | ||
### Fgets | ||
synchronous line-at-a-time stream reader. Returns the next buffered | ||
line or the empty string "" if the buffer is currently empty. 3x faster | ||
than require('readline'), and works like C fgets(), it doesn't modify | ||
the input. Note: the caller must periodically yield with setImmediate | ||
or setTimeout to allow the buffer to fill. | ||
NOTE: Fgets is being split out of arlib as its own module [qfgets](https://www.npmjs.org/package/qfgets). | ||
#### fgets( ) | ||
var fs = require('fs'); | ||
var Fgets = require('arlib').Fgets; | ||
var fp = new Fgets(fs.createReadStream('/etc/motd', 'r')); | ||
// line = fp.fgets(); | ||
#### feof( ) | ||
returns true when fgets has no more lines to return | ||
var Fgets = require('arlib').Fgets; | ||
var fp = new Fgets('/etc/motd'); // use buit-in FileReader | ||
var contents = ""; | ||
(function readfile() { | ||
for (var i=0; i<40; i++) contents += fp.fgets(); | ||
if (!fp.feof()) setImmediate(readfile); // yield periodically | ||
})(); | ||
#### FileReader | ||
fast file reader to feed data to fgets. A smidge faster than a read stream | ||
created with a reasonable highWaterMark (50% faster than a stream created with | ||
defaults) | ||
var FileReader = require('arlib').FileReader; | ||
var fp = new Fgets(new FileReader('/etc/motd')); | ||
// line = fp.fgets(); | ||
### phpdate( format, timestamp ) | ||
@@ -105,3 +69,4 @@ | ||
phpdate('Y-m-d H:i:s.u T'); // 2014-10-18 04:56:53.437000 EDT | ||
var phpdate = require('arlib/phpdate'); | ||
phpdate('Y-m-d H:i:s.u T'); // 2014-10-18 04:56:53.437000 EDT | ||
@@ -112,3 +77,4 @@ ### str_repeat( string, count ) | ||
str_repeat("x", 5); // "xxxxx" | ||
var str_repeat = require('arlib/str_repeat'); | ||
str_repeat("x", 5); // "xxxxx" | ||
@@ -122,10 +88,19 @@ ### timeit( count, function, [message], [callback] ) | ||
timeit = require('./timeit'); | ||
var timeit = require('arlib/timeit'); | ||
var fs = require('fs'); | ||
function opencloseSync() { var fd = fs.openSync('/etc/motd', 'r'); fs.closeSync(fd); } | ||
function opencloseSync() { | ||
var fd = fs.openSync('/etc/motd', 'r'); | ||
fs.closeSync(fd); | ||
} | ||
timeit(10000, function(){ opencloseSync(); }); | ||
// AR: "function (){ opencloseSync(); }": 10000 loops in 0.0210 sec: 475221.68 / sec, 0.00210 ms each | ||
function openclose(cb) { fs.open('/etc/motd', 'r', function(err, fd) { cb(fd); }); } | ||
timeit(10000, function(cb){ openclose(function(){ cb(); }); }, "async open/close:", function(){ }); | ||
// async open/close: "function (cb){ openclose(function(){ cb(); }); }": 10000 loops in 0.2396 sec: 41740.64 / sec, 0.02396 ms each | ||
function opencloseAsync(cb) { | ||
fs.open('/etc/motd', 'r', function(err, fd) { | ||
if (err) throw err; | ||
fs.close(fd, function(err) { cb(fd); }); | ||
}); | ||
} | ||
timeit(10000, function(cb){ opencloseAsync(function(){ cb(); }); }, "async open/close:", function(){ }); | ||
// async open/close: "function (cb){ opencloseAsync(function(){ cb(); }); }": 10000 loops in 0.2890 sec: 34598.11 / sec, 0.02890 ms each |
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
0
996
1
43695
102
- Removedfs-ext@*
- Removedfs-ext@2.1.1(transitive)
- Removednan@2.22.0(transitive)