diff options
Diffstat (limited to 'deps/npm/node_modules/fs-write-stream-atomic/node_modules')
8 files changed, 234 insertions, 0 deletions
diff --git a/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/.npmignore b/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/.npmignore new file mode 100644 index 0000000000..3c3629e647 --- /dev/null +++ b/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/LICENSE b/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/LICENSE new file mode 100644 index 0000000000..19d5f4bce5 --- /dev/null +++ b/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Nadav Ivgi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.
\ No newline at end of file diff --git a/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/README.md b/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/README.md new file mode 100644 index 0000000000..0940763fa9 --- /dev/null +++ b/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/README.md @@ -0,0 +1,40 @@ +# iferr + +Higher-order functions for easier error handling. + +`if (err) return cb(err);` be gone! + +## Install +```bash +npm install iferr +``` + +## Use + +### JavaScript example +```js +var iferr = require('iferr'); + +function get_friends_count(id, cb) { + User.load_user(id, iferr(cb, function(user) { + user.load_friends(iferr(cb, function(friends) { + cb(null, friends.length); + })); + })); +} +``` + +### CoffeeScript example +```coffee +iferr = require 'iferr' + +get_friends_count = (id, cb) -> + User.load_user id, iferr cb, (user) -> + user.load_friends iferr cb, (friends) -> + cb null, friends.length +``` + +(TODO: document tiferr, throwerr and printerr) + +## License +MIT diff --git a/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/index.coffee b/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/index.coffee new file mode 100644 index 0000000000..da6d00719f --- /dev/null +++ b/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/index.coffee @@ -0,0 +1,24 @@ +# Delegates to `succ` on sucecss or to `fail` on error +# ex: Thing.load 123, iferr cb, (thing) -> ... +iferr = (fail, succ) -> (err, a...) -> + if err? then fail err + else succ? a... + +# Like iferr, but also catches errors thrown from `succ` and passes to `fail` +tiferr = (fail, succ) -> iferr fail, (a...) -> + try succ a... + catch err then fail err + +# Delegate to the success function on success, or throw the error otherwise +# ex: Thing.load 123, throwerr (thing) -> ... +throwerr = iferr.bind null, (err) -> throw err + +# Prints errors when one is passed, or does nothing otherwise +# ex: thing.save printerr +printerr = iferr (err) -> console.error err.stack or err + +module.exports = exports = iferr +exports.iferr = iferr +exports.tiferr = tiferr +exports.throwerr = throwerr +exports.printerr = printerr diff --git a/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/index.js b/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/index.js new file mode 100644 index 0000000000..78fce3d2b0 --- /dev/null +++ b/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/index.js @@ -0,0 +1,49 @@ +// Generated by CoffeeScript 1.7.1 +(function() { + var exports, iferr, printerr, throwerr, tiferr, + __slice = [].slice; + + iferr = function(fail, succ) { + return function() { + var a, err; + err = arguments[0], a = 2 <= arguments.length ? __slice.call(arguments, 1) : []; + if (err != null) { + return fail(err); + } else { + return typeof succ === "function" ? succ.apply(null, a) : void 0; + } + }; + }; + + tiferr = function(fail, succ) { + return iferr(fail, function() { + var a, err; + a = 1 <= arguments.length ? __slice.call(arguments, 0) : []; + try { + return succ.apply(null, a); + } catch (_error) { + err = _error; + return fail(err); + } + }); + }; + + throwerr = iferr.bind(null, function(err) { + throw err; + }); + + printerr = iferr(function(err) { + return console.error(err.stack || err); + }); + + module.exports = exports = iferr; + + exports.iferr = iferr; + + exports.tiferr = tiferr; + + exports.throwerr = throwerr; + + exports.printerr = printerr; + +}).call(this); diff --git a/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/package.json b/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/package.json new file mode 100644 index 0000000000..5ac59fc8ee --- /dev/null +++ b/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/package.json @@ -0,0 +1,55 @@ +{ + "_from": "iferr@^0.1.5", + "_id": "iferr@0.1.5", + "_inBundle": false, + "_integrity": "sha1-xg7taebY/bazEEofy8ocGS3FtQE=", + "_location": "/fs-write-stream-atomic/iferr", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "iferr@^0.1.5", + "name": "iferr", + "escapedName": "iferr", + "rawSpec": "^0.1.5", + "saveSpec": null, + "fetchSpec": "^0.1.5" + }, + "_requiredBy": [ + "/fs-write-stream-atomic" + ], + "_resolved": "https://registry.npmjs.org/iferr/-/iferr-0.1.5.tgz", + "_shasum": "c60eed69e6d8fdb6b3104a1fcbca1c192dc5b501", + "_spec": "iferr@^0.1.5", + "_where": "/Users/rebecca/code/npm/node_modules/fs-write-stream-atomic", + "author": { + "name": "Nadav Ivgi" + }, + "bugs": { + "url": "https://github.com/shesek/iferr/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "Higher-order functions for easier error handling", + "devDependencies": { + "coffee-script": "^1.7.1", + "mocha": "^1.18.2" + }, + "homepage": "https://github.com/shesek/iferr", + "keywords": [ + "error", + "errors" + ], + "license": "MIT", + "main": "index.js", + "name": "iferr", + "repository": { + "type": "git", + "url": "git+https://github.com/shesek/iferr.git" + }, + "scripts": { + "prepublish": "coffee -c index.coffee", + "test": "mocha" + }, + "version": "0.1.5" +} diff --git a/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/test/index.coffee b/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/test/index.coffee new file mode 100644 index 0000000000..be0bc56fdf --- /dev/null +++ b/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/test/index.coffee @@ -0,0 +1,42 @@ +{ iferr, tiferr, throwerr } = require '../index.coffee' +{ equal: eq, throws } = require 'assert' + +invoke_fail = (cb) -> cb new Error 'callback error' +invoke_succ = (cb) -> cb null +throw_error = -> throw new Error 'thrown' + +describe 'iferr', -> + it 'calls the error callback on errors', (done) -> + invoke_fail iferr( + (err) -> + eq err.message, 'callback error' + do done + -> + done new Error 'shouldn\'t call the success callback' + ) + + it 'calls the success callback on success', (done) -> + invoke_succ iferr( + -> done new Error 'shouldn\'t call the error callback' + done + ) + +describe 'tiferr', -> + it 'catches errors in the success callback', (done) -> + invoke_succ tiferr( + (err) -> + eq err.message, 'thrown' + do done + throw_error + ) + +describe 'throwerr', -> + it 'throws errors passed to the callback', (done)-> + try invoke_fail throwerr -> + done 'shouldn\'t call the success callback' + catch err + eq err.message, 'callback error' + do done + + it 'delegates to the success callback otherwise', (done) -> + invoke_succ throwerr done diff --git a/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/test/mocha.opts b/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/test/mocha.opts new file mode 100644 index 0000000000..019defcf15 --- /dev/null +++ b/deps/npm/node_modules/fs-write-stream-atomic/node_modules/iferr/test/mocha.opts @@ -0,0 +1,2 @@ +--compilers coffee:coffee-script/register +--reporter spec |