[Pkg-javascript-commits] [node-deprecated] 01/04: New upstream version 0.0.1

Sagar Ippalpalli isaagar-guest at moszumanska.debian.org
Sun Nov 6 08:25:12 UTC 2016


This is an automated email from the git hooks/post-receive script.

isaagar-guest pushed a commit to branch master
in repository node-deprecated.

commit 98f87d54d38840a8da43befbf9a4bcec1e2080b3
Author: Sagar Ippalpalli <i.vikram15 at gmail.com>
Date:   Thu Oct 27 03:16:05 2016 +0530

    New upstream version 0.0.1
---
 .gitignore     |  6 ++++++
 .npmignore     |  6 ++++++
 .travis.yml    |  6 ++++++
 LICENSE        | 20 ++++++++++++++++++++
 README.md      | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 index.js       | 39 +++++++++++++++++++++++++++++++++++++++
 package.json   | 35 +++++++++++++++++++++++++++++++++++
 test/field.js  | 44 ++++++++++++++++++++++++++++++++++++++++++++
 test/method.js | 32 ++++++++++++++++++++++++++++++++
 9 files changed, 239 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b5ef13a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+.DS_Store
+*.log
+node_modules
+build
+*.node
+components
\ No newline at end of file
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 0000000..b5ef13a
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,6 @@
+.DS_Store
+*.log
+node_modules
+build
+*.node
+components
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..33ad9f8
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,6 @@
+language: node_js
+node_js:
+  - "0.9"
+  - "0.10"
+after_script:
+  - npm run coveralls
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100755
index 0000000..7cbe012
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2014 Fractal <contact at wearefractal.com>
+
+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.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..27f025f
--- /dev/null
+++ b/README.md
@@ -0,0 +1,51 @@
+# 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
+
+<table>
+<tr> 
+<td>Package</td><td>deprecated</td>
+</tr>
+<tr>
+<td>Description</td>
+<td>Tool for deprecating things</td>
+</tr>
+<tr>
+<td>Node Version</td>
+<td>>= 0.9</td>
+</tr>
+</table>
+
+## 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.io
\ No newline at end of file
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..f689e9c
--- /dev/null
+++ b/index.js
@@ -0,0 +1,39 @@
+var 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;
\ No newline at end of file
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..5556b90
--- /dev/null
+++ b/package.json
@@ -0,0 +1,35 @@
+{
+  "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 <contact at wearefractal.com> (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"
+    }
+  ]
+}
diff --git a/test/field.js b/test/field.js
new file mode 100644
index 0000000..91a7029
--- /dev/null
+++ b/test/field.js
@@ -0,0 +1,44 @@
+var 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();
+  });
+});
\ No newline at end of file
diff --git a/test/method.js b/test/method.js
new file mode 100644
index 0000000..615ba94
--- /dev/null
+++ b/test/method.js
@@ -0,0 +1,32 @@
+var 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();
+  });
+});
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-deprecated.git



More information about the Pkg-javascript-commits mailing list