pax_global_header00006660000000000000000000000064131056627130014516gustar00rootroot0000000000000052 comment=51037b0b76cec197289e4d5c90aad3990a87ad9e deprecated-0.0.2/000077500000000000000000000000001310566271300136155ustar00rootroot00000000000000deprecated-0.0.2/.gitignore000066400000000000000000000000641310566271300156050ustar00rootroot00000000000000.DS_Store *.log node_modules build *.node componentsdeprecated-0.0.2/.npmignore000066400000000000000000000000641310566271300156140ustar00rootroot00000000000000.DS_Store *.log node_modules build *.node componentsdeprecated-0.0.2/.travis.yml000066400000000000000000000001231310566271300157220ustar00rootroot00000000000000language: node_js node_js: - "0.9" - "0.10" after_script: - npm run coverallsdeprecated-0.0.2/LICENSE000077500000000000000000000020661310566271300146310ustar00rootroot00000000000000Copyright (c) 2014 Fractal 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. deprecated-0.0.2/README.md000066400000000000000000000026751310566271300151060ustar00rootroot00000000000000# deprecated [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Dependency Status][david-image]][david-url] ## Information
Packagedeprecated
Description Tool for deprecating things
Node Version >= 0.9
## Usage ```javascript var oldfn = function(a,b) { return a+b; }; // returns a new wrapper function that logs the deprecated function once var somefn = deprecated.method('dont use this anymore', console.log, oldfn); var someobj = {}; // set up a getter/set for field that logs deprecated message once deprecated.field('dont use this anymore', console.log, someobj, 'a', 123); console.log(someobj.a); // 123 ``` [npm-url]: https://npmjs.org/package/deprecated [npm-image]: https://badge.fury.io/js/deprecated.png [travis-url]: https://travis-ci.org/wearefractal/deprecated [travis-image]: https://travis-ci.org/wearefractal/deprecated.png?branch=master [coveralls-url]: https://coveralls.io/r/wearefractal/deprecated [coveralls-image]: https://coveralls.io/repos/wearefractal/deprecated/badge.png [depstat-url]: https://david-dm.org/wearefractal/deprecated [depstat-image]: https://david-dm.org/wearefractal/deprecated.png [david-url]: https://david-dm.org/wearefractal/deprecated [david-image]: https://david-dm.org/wearefractal/deprecated.png?theme=shields.iodeprecated-0.0.2/index.d.ts000066400000000000000000000003511310566271300155150ustar00rootroot00000000000000declare module 'deprecated' { export function method (msg: string, log: (...t: any[]) => void ,t: T): T export function field (msg: string, log: (...t: any[]) => void , t: T, prop: string, value: V): T }deprecated-0.0.2/index.js000066400000000000000000000013211310566271300152570ustar00rootroot00000000000000var deprecated = { method: function(msg, log, fn) { var called = false; return function(){ if (!called) { called = true; log(msg); } return fn.apply(this, arguments); }; }, field: function(msg, log, parent, field, val) { var called = false; var getter = function(){ if (!called) { called = true; log(msg); } return val; }; var setter = function(v) { if (!called) { called = true; log(msg); } val = v; return v; }; Object.defineProperty(parent, field, { get: getter, set: setter, enumerable: true }); return; } }; module.exports = deprecated;deprecated-0.0.2/package.json000066400000000000000000000016721310566271300161110ustar00rootroot00000000000000{ "name": "deprecated", "description": "Tool for deprecating things", "version": "0.0.2", "homepage": "http://github.com/wearefractal/deprecated", "repository": "git://github.com/wearefractal/deprecated.git", "author": "Fractal (http://wearefractal.com/)", "main": "./index.js", "typings": "./index.d.ts", "dependencies": {}, "devDependencies": { "mocha": "~1.17.0", "should": "~3.1.0", "mocha-lcov-reporter": "~0.0.1", "coveralls": "~2.6.1", "istanbul": "~0.2.3", "rimraf": "~2.2.5", "jshint": "~2.4.1" }, "scripts": { "test": "mocha --reporter spec && jshint", "coveralls": "istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage" }, "engines": { "node": ">= 0.9" }, "licenses": [ { "type": "MIT", "url": "http://github.com/wearefractal/deprecated/raw/master/LICENSE" } ] } deprecated-0.0.2/test/000077500000000000000000000000001310566271300145745ustar00rootroot00000000000000deprecated-0.0.2/test/field.js000066400000000000000000000020171310566271300162150ustar00rootroot00000000000000var deprecated = require('../'); var should = require('should'); require('mocha'); describe('field()', function() { it('should return a wrapped function that logs once on get', function(done) { var message = 'testing'; var scope = { a: 1 }; var obj = {}; var logged = false; var log = function(msg){ msg.should.equal(message); logged.should.equal(false); logged = true; }; deprecated.field(message, log, obj, 'a', 123); obj.a.should.equal(123); obj.a = 1234; obj.a.should.equal(1234); logged.should.equal(true); done(); }); it('should return a wrapped function that logs once on set', function(done) { var message = 'testing'; var scope = { a: 1 }; var obj = {}; var logged = false; var log = function(msg){ msg.should.equal(message); logged.should.equal(false); logged = true; }; deprecated.field(message, log, obj, 'a', 123); obj.a = 1234; logged.should.equal(true); done(); }); });deprecated-0.0.2/test/method.js000066400000000000000000000014431310566271300164140ustar00rootroot00000000000000var deprecated = require('../'); var should = require('should'); require('mocha'); describe('method()', function() { it('should return a wrapped function that logs once', function(done) { var message = 'testing'; var scope = { a: 1 }; var logged = false; var log = function(msg){ msg.should.equal(message); logged.should.equal(false); logged = true; }; var fn = deprecated.method(message, log, function(one, two){ this.should.equal(scope); one.should.equal(1); two.should.equal(2); return one+two; }); fn.bind(scope)(1,2).should.equal(3); fn.bind(scope)(1,2).should.equal(3); fn.bind(scope)(1,2).should.equal(3); fn.bind(scope)(1,2).should.equal(3); logged.should.equal(true); done(); }); });