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

workshopper-adventure-storage

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

workshopper-adventure-storage - npm Package Compare versions

Comparing version 1.0.3 to 2.0.0

27

index.js

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

function reset (cb) {
rimraf(dir, function (err) {
if (err) return cb(err)
cb()
})
rimraf.sync(dir)
}

@@ -27,10 +24,5 @@

*/
function save (name, data, cb) {
mkdirp(dir, function (err) {
if (err) return cb(err)
fs.writeFile(fileName(name), JSON.stringify(data), function (err, saveData) {
if (err) return cb(err)
cb()
})
})
function save (name, data) {
mkdirp.sync(dir)
fs.writeFileSync(fileName(name), JSON.stringify(data))
}

@@ -43,11 +35,4 @@

var file = fileName(name)
fs.readFile(file, 'utf8', function (err, fileData) {
if (err) return cb(err)
try {
fileData = JSON.parse(fileData)
} catch (e) {
return cb(e)
}
cb(null, fileData)
})
var fileData = fs.readFileSync(file, 'utf8')
return JSON.parse(fileData)
}

@@ -54,0 +39,0 @@

{
"name": "workshopper-adventure-storage",
"version": "1.0.3",
"version": "2.0.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -75,5 +75,5 @@ # workshopper-adventure-storage

[travis-url]: https://travis-ci.org/kid-icarus/workshopper-adventure-storage
[travis-image]: https://travis-ci.org/kid-icarus/workshopper-adventure-storage.png?branch=master
[coveralls-url]: https://coveralls.io/github/kid-icarus/workshopper-adventure-storage?branch=master
[coveralls-image]: https://coveralls.io/repos/github/kid-icarus/workshopper-adventure-storage/badge.svg?branch=master
[travis-url]: https://travis-ci.org/workshopper/workshopper-adventure-storage
[travis-image]: https://travis-ci.org/workshopper/workshopper-adventure-storage.png?branch=master
[coveralls-url]: https://coveralls.io/github/workshopper/workshopper-adventure-storage?branch=master
[coveralls-image]: https://coveralls.io/repos/github/workshopper/workshopper-adventure-storage/badge.svg?branch=master

@@ -10,18 +10,9 @@ var storage = require('..')

/**
* Initialize storage and save a file.
*/
beforeEach(function (done) {
function writeBadJson (err) {
if (err) return done(err)
fs.writeFile(invalidJson, '{', done)
}
testStorage.reset(function (err) {
if (err) return done(err)
testStorage.save('index', {
foo: 'bar'
}, writeBadJson)
})
beforeEach(function () {
testStorage.reset()
testStorage.save('index', { foo: 'bar' })
fs.writeFileSync(invalidJson, '{')
})

@@ -51,7 +42,5 @@

it('should retrive a stored file', function (done) {
testStorage.get('index', function (err, file) {
if (err) return done(err)
expect(file.foo).to.equal('bar')
done()
})
var file = testStorage.get('index')
expect(file.foo).to.equal('bar')
done()
})

@@ -62,9 +51,8 @@

if (err) return done(err)
var fileData
try {
fileData = JSON.parse(data)
JSON.parse(data)
} catch (e) {
return done()
return done(err)
}
done('read the file!')
done()
})

@@ -76,7 +64,6 @@ })

it('should clean the storage directory', function (done) {
testStorage.reset(function () {
fs.stat('./foo/bar', function (err, stats) {
if (err && err.code === 'ENOENT') return done()
done('file still exists!')
})
testStorage.reset()
fs.stat('./foo/bar', function (err, stats) {
if (err && err.code === 'ENOENT') return done()
done('file still exists!')
})

@@ -83,0 +70,0 @@ })

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