diff --git a/README.md b/README.md index 5e7d928..f71a0a7 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,7 @@ # middlestack.js -# Middleware for functions +# DEPRECATED -## Current status +This project has been renamed `shimstack`. -[![NPM version](https://img.shields.io/npm/v/middlestack.svg)](https://www.npmjs.com/package/middlestack) -[![Build Status](https://img.shields.io/travis/overlookmotel/middlestack/master.svg)](http://travis-ci.org/overlookmotel/middlestack) -[![Dependency Status](https://img.shields.io/david/overlookmotel/middlestack.svg)](https://david-dm.org/overlookmotel/middlestack) -[![Dev dependency Status](https://img.shields.io/david/dev/overlookmotel/middlestack.svg)](https://david-dm.org/overlookmotel/middlestack) -[![Coverage Status](https://img.shields.io/coveralls/overlookmotel/middlestack/master.svg)](https://coveralls.io/r/overlookmotel/middlestack) - -## Usage - -## Tests - -Use `npm test` to run the tests. Use `npm run cover` to check coverage. - -## Changelog - -See changelog.md - -## Issues - -If you discover a bug, please raise an issue on Github. https://github.com/overlookmotel/middlestack/issues - -## Contribution - -Pull requests are very welcome. Please: - -* ensure all tests pass before submitting PR -* add an entry to changelog -* add tests for new features -* document new functionality/API additions in README +Please use [shimstack](https://www.npmjs.com/package/shimstack) instead. diff --git a/changelog.md b/changelog.md index 6e475e9..2e8f47a 100644 --- a/changelog.md +++ b/changelog.md @@ -12,3 +12,7 @@ ## 0.1.2 * Error name capitalized + +## Next + +* Deprecated project - renamed `shimstack` diff --git a/lib/index.js b/lib/index.js index 6a598e0..bba36be 100644 --- a/lib/index.js +++ b/lib/index.js @@ -2,88 +2,4 @@ // middlestack module // -------------------- -// modules -var util = require('util'), - co = require('co-bluebird'), - isGeneratorFn = require('is-generator').fn, - _ = require('lodash'); - -// exports -var middlestack = module.exports = function(obj, methodName, options, fn) { - // conform arguments - if (typeof methodName == 'function') { - fn = methodName; - methodName = undefined; - options = undefined; - } else if (typeof methodName == 'object') { - fn = options; - options = methodName; - methodName = undefined; - } else if (typeof options == 'function') { - fn = options; - options = undefined; - } - - // conform options - options = _.extend({ - // name: undefined - lastArg: false - }, options || {}); - - // get method - var method = (methodName ? obj[methodName] : obj); - if (typeof method != 'function') throw new middlestack.Error('You can only middlestack a function'); - - // if not already stackified, middlestack method - if (!method.__middlestack) method = convertToStack(method, obj, methodName); - - // get function name - if (options.name === undefined && fn.name) options.name = fn.name; - - // co-ify generators - if (isGeneratorFn(fn)) fn = co.wrap(fn); - - // add fn to stack - method.__middlestack.stack.push({fn: fn, name: options.name, lastArg: options.lastArg}); - - return method; -}; - -function convertToStack(origMethod, obj, methodName) { - // create stackified function - var method = function() { - var _this = this, - stack = method.__middlestack.stack, - i = 0; - - var next = function() { - if (i == stack.length) return method.__middlestack.final.apply(_this, arguments); - - var item = stack[i]; - i++; - - var args = Array.prototype.slice.call(arguments); - args[item.lastArg ? args.length : item.fn.length - 1] = next; - - return item.fn.apply(_this, args); - }; - - return next.apply(this, arguments); - }; - - method.__middlestack = {stack: [], final: origMethod}; - - // write stackified method to obj - if (methodName) obj[methodName] = method; - - // return stackified method - return method; -} - -middlestack.Error = function(message) { - var tmp = Error.call(this, message); - tmp.name = this.name = 'MiddlestackError'; - this.message = tmp.message; - Error.captureStackTrace(this, this.constructor); -}; -util.inherits(middlestack.Error, Error); +module.exports = require('shimstack'); diff --git a/package.json b/package.json index e09a2fe..e082f53 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "middlestack", "version": "0.1.2", - "description": "Middleware for functions", + "description": "DEPRECATED", "main": "./lib/", "author": { "name": "Overlook Motel" @@ -14,9 +14,7 @@ "url": "https://github.com/overlookmotel/middlestack/issues" }, "dependencies": { - "co-bluebird": "0.0.2", - "is-generator": "1.0.0", - "lodash": "3.8.0" + "shimstack": "*" }, "devDependencies": { "mocha": "^2.2.4", @@ -26,11 +24,6 @@ "coveralls": "^2.11.2" }, "keywords": [ - "middleware", - "function", - "functions", - "shim", - "stack" ], "scripts": { "test": "make test",