pax_global_header00006660000000000000000000000064122705730750014522gustar00rootroot0000000000000052 comment=c2373328e7d7e8e1a9ad3691f305ea1d12b67153 deprecated-c2373328e7d7e8e1a9ad3691f305ea1d12b67153/000077500000000000000000000000001227057307500204625ustar00rootroot00000000000000deprecated-c2373328e7d7e8e1a9ad3691f305ea1d12b67153/.gitignore000066400000000000000000000000641227057307500224520ustar00rootroot00000000000000.DS_Store *.log node_modules build *.node componentsdeprecated-c2373328e7d7e8e1a9ad3691f305ea1d12b67153/.npmignore000066400000000000000000000000641227057307500224610ustar00rootroot00000000000000.DS_Store *.log node_modules build *.node componentsdeprecated-c2373328e7d7e8e1a9ad3691f305ea1d12b67153/.travis.yml000066400000000000000000000001231227057307500225670ustar00rootroot00000000000000language: node_js node_js: - "0.9" - "0.10" after_script: - npm run coverallsdeprecated-c2373328e7d7e8e1a9ad3691f305ea1d12b67153/LICENSE000077500000000000000000000020661227057307500214760ustar00rootroot00000000000000Copyright (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-c2373328e7d7e8e1a9ad3691f305ea1d12b67153/README.md000066400000000000000000000026751227057307500217530ustar00rootroot00000000000000# 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-c2373328e7d7e8e1a9ad3691f305ea1d12b67153/index.js000066400000000000000000000013211227057307500221240ustar00rootroot00000000000000var 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-c2373328e7d7e8e1a9ad3691f305ea1d12b67153/package.json000066400000000000000000000016351227057307500227550ustar00rootroot00000000000000{ "name":"deprecated", "description":"Tool for deprecating things", "version":"0.0.1", "homepage":"http://github.com/wearefractal/deprecated", "repository":"git://github.com/wearefractal/deprecated.git", "author":"Fractal (http://wearefractal.com/)", "main":"./index.js", "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-c2373328e7d7e8e1a9ad3691f305ea1d12b67153/test/000077500000000000000000000000001227057307500214415ustar00rootroot00000000000000deprecated-c2373328e7d7e8e1a9ad3691f305ea1d12b67153/test/field.js000066400000000000000000000020171227057307500230620ustar00rootroot00000000000000var 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-c2373328e7d7e8e1a9ad3691f305ea1d12b67153/test/method.js000066400000000000000000000014431227057307500232610ustar00rootroot00000000000000var 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(); }); });