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

steno

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

steno - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

6

benchmark.js

@@ -12,3 +12,3 @@ var fs = require('fs')

var max = 20 * 1000
var max = 10 * 1000

@@ -23,8 +23,8 @@ benchmark(function(done) {

writer.callback = function(data, next) {
writer.setCallback(function(data, next) {
if (data === max) done('steno.write ')
next()
}
})
for (var i = 0; i <= max; i++) writer.write(i)
})

@@ -1,45 +0,1 @@

// var fs = require('fs')
// var util = require('util')
// var events = require('events')
// var writers = {}
// function Writer(filename) {
// events.EventEmitter.call(this)
// this.filename = filename
// }
// util.inherits(Writer, events.EventEmitter)
// Writer.prototype.write = function(data) {
// if (this.writing) {
// this.next = data
// } else if (data !== this.last) {
// this.writing = true
// this.last = data
// var self = this
// fs.writeFile(this.filename, data, function(err) {
// if (err) throw err
// self.writing = false
// self.emit('flush', data)
// if (self.next) self.write.apply(self, [self.next])
// })
// }
// }
// module.exports = function(filename) {
// return writers[filename] = writers[filename] || new Writer(filename)
// }
var fs = require('fs')

@@ -58,7 +14,9 @@ var util = require('util')

Writer.prototype.callback = function(data, next) { next() }
Writer.prototype.setCallback = function(callback) {
this.callback = callback
}
Writer.prototype.write = function(data) {
if (this.writing) {
if (this.lock) {

@@ -69,3 +27,3 @@ this.next = data

this.writing = true
this.lock = true
this.last = data

@@ -78,6 +36,12 @@

self.writing = false
self.callback(data, function() {
if (self.next) self.write(self.next)
})
function next() {
self.lock = false
if (self.next) {
var data = self.next
self.next = null
self.write(data)
}
}
self.callback ? self.callback(data, next) : next()
})

@@ -84,0 +48,0 @@

{
"name": "steno",
"version": "0.1.0",
"version": "0.1.1",
"description": "File writer",
"main": "index.js",
"scripts": {
"test": "node test"
"test": "node test",
"prepush": "npm test"
},

@@ -28,4 +29,5 @@ "repository": {

"devDependencies": {
"husky": "^0.6.1",
"tape": "^3.0.1"
}
}

@@ -1,2 +0,2 @@

# steno
# steno ![](http://img.shields.io/npm/v/steno.svg?style=flat) ![](http://img.shields.io/travis/typicode/steno.svg?style=flat)

@@ -28,3 +28,3 @@ > Super fast non-blocking file writer for Node.

```javascript
steno('tmp-file.txt').callback = function(data, next) {
steno('tmp-file.txt').setCallback(function(data, next) {
console.log(data + ' has been written to ' + this.filename)

@@ -35,3 +35,3 @@ fs.rename('tmp-file.txt', 'file.txt', function(err) {

})
}
})
```

@@ -29,3 +29,3 @@ var fs = require('fs')

writer.callback = function(data, next) {
writer.setCallback(function(data, next) {
if (data === max) {

@@ -35,3 +35,3 @@ t.equal(+fs.readFileSync('tmp.txt'), max)

next()
}
})

@@ -38,0 +38,0 @@ for (var i= 0; i <= max; i++) {

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