New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

arlib

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arlib - npm Package Compare versions

Comparing version 0.0.13 to 0.0.14

8

index.js

@@ -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
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