[Pkg-javascript-commits] [node-is-equal-shallow] 01/03: Import Upstream version 0.1.3

Shanavas M shanavas-guest at moszumanska.debian.org
Fri Oct 28 18:56:20 UTC 2016


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

shanavas-guest pushed a commit to branch master
in repository node-is-equal-shallow.

commit 7b6a86d5ccf97e9f355b1501892a164229c9e25d
Author: Shanavas M <shanavas.m2 at gmail.com>
Date:   Fri Oct 28 10:40:06 2016 +0000

    Import Upstream version 0.1.3
---
 .editorconfig  | 17 +++++++++++
 .gitattributes | 10 +++++++
 .gitignore     | 13 +++++++++
 .jshintrc      | 18 ++++++++++++
 .travis.yml    |  8 ++++++
 .verb.md       | 70 +++++++++++++++++++++++++++++++++++++++++++++
 LICENSE        | 21 ++++++++++++++
 README.md      | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 index.js       | 27 ++++++++++++++++++
 package.json   | 54 +++++++++++++++++++++++++++++++++++
 test.js        | 38 +++++++++++++++++++++++++
 11 files changed, 366 insertions(+)

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..2eed47c
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,17 @@
+# http://editorconfig.org
+root = true
+
+[*]
+indent_style = space
+indent_size = 2
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false
+
+[test/fixtures/*]
+insert_final_newline = false
+trim_trailing_whitespace = false
\ No newline at end of file
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..4a3f1d3
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,10 @@
+# Enforce Unix newlines
+* text eol=lf
+
+# binaries
+*.ai binary
+*.psd binary
+*.jpg binary
+*.gif binary
+*.png binary
+*.jpeg binary
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8d1d506
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,13 @@
+*.DS_Store
+*.DS_store
+*.sublime-*
+_gh_pages
+bower_components
+node_modules
+npm-debug.log
+actual
+test/actual
+temp
+tmp
+TODO.md
+vendor
\ No newline at end of file
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..6e5a84a
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,18 @@
+{
+  "asi": false,
+  "boss": true,
+  "curly": true,
+  "eqeqeq": true,
+  "eqnull": true,
+  "esnext": true,
+  "immed": true,
+  "latedef": false,
+  "laxcomma": false,
+  "mocha": true,
+  "newcap": true,
+  "noarg": true,
+  "node": true,
+  "sub": true,
+  "undef": true,
+  "unused": true
+}
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..efe94c0
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,8 @@
+sudo: false
+language: node_js
+node_js:
+  - "0.10"
+  - "0.12"
+  - "iojs"
+git:
+  depth: 10
\ No newline at end of file
diff --git a/.verb.md b/.verb.md
new file mode 100644
index 0000000..f6af2ae
--- /dev/null
+++ b/.verb.md
@@ -0,0 +1,70 @@
+# {%= name %} {%= badge("fury") %} {%= badge("travis") %}
+
+> {%= description %}
+
+The purpose of this lib is to do the fastest comparison possible of two objects when the values will predictably be primitives. 
+
+- only compares objects.
+- only compares the first level of each object
+- values must be primitives. If a value is not a primitive, even if the values are the same, `false` is returned.
+
+{%= include("install-npm", {save: true}) %}
+
+
+## Usage
+
+```js
+var equals = require('{%= name %}');
+equals(object_a, object_b);
+```
+
+**Examples**
+
+```js
+equals({a: true, b: true}, {a: true, b: true});
+//=> 'true'
+
+equals({a: true, b: false}, {c: false, b: false});
+//=> 'false'
+
+equals({a: true, b: false}, {a: false, b: false});
+//=> 'false'
+```
+
+Strict comparison for equality:
+
+```js
+equals({a: true, b: true}, {a: true, b: 'true'});
+//=> 'false'
+```
+
+When values are not primitives, `false` is always returned:
+
+```js
+equals({ b: {}}, { b: {}});
+//=> 'false'
+
+equals({ b: []}, { b: []});
+//=> 'false'
+```
+
+## Related projects
+{%= verbiage.related.description %}  
+{%= related(verbiage.related.list) %}  
+
+## Running tests
+{%= include("tests") %}
+
+## Contributing
+{%= include("contributing") %}
+
+## Author
+{%= include("author") %}
+
+## License
+{%= copyright() %}
+{%= license() %}
+
+***
+
+{%= include("footer") %}
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..65f90ac
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2015, Jon Schlinkert.
+
+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..1142276
--- /dev/null
+++ b/README.md
@@ -0,0 +1,90 @@
+# is-equal-shallow [![NPM version](https://badge.fury.io/js/is-equal-shallow.svg)](http://badge.fury.io/js/is-equal-shallow)  [![Build Status](https://travis-ci.org/jonschlinkert/is-equal-shallow.svg)](https://travis-ci.org/jonschlinkert/is-equal-shallow)
+
+> Does a shallow comparison of two objects, returning false if the keys or values differ.
+
+The purpose of this lib is to do the fastest comparison possible of two objects when the values will predictably be primitives.
+
+* only compares objects.
+* only compares the first level of each object
+* values must be primitives. If a value is not a primitive, even if the values are the same, `false` is returned.
+
+Install with [npm](https://www.npmjs.com/)
+
+```sh
+$ npm i is-equal-shallow --save
+```
+
+## Usage
+
+```js
+var equals = require('is-equal-shallow');
+equals(object_a, object_b);
+```
+
+**Examples**
+
+```js
+equals({a: true, b: true}, {a: true, b: true});
+//=> 'true'
+
+equals({a: true, b: false}, {c: false, b: false});
+//=> 'false'
+
+equals({a: true, b: false}, {a: false, b: false});
+//=> 'false'
+```
+
+Strict comparison for equality:
+
+```js
+equals({a: true, b: true}, {a: true, b: 'true'});
+//=> 'false'
+```
+
+When values are not primitives, `false` is always returned:
+
+```js
+equals({ b: {}}, { b: {}});
+//=> 'false'
+
+equals({ b: []}, { b: []});
+//=> 'false'
+```
+
+## Related projects
+
+Other object utils:
+
+* [clone-deep](https://github.com/jonschlinkert/clone-deep): Recursively (deep) clone JavaScript native types, like Object, Array, RegExp, Date as well as primitives.
+* [for-in](https://github.com/jonschlinkert/for-in): Iterate over the own and inherited enumerable properties of an objecte, and return an object… [more](https://github.com/jonschlinkert/for-in)
+* [for-own](https://github.com/jonschlinkert/for-own): Iterate over the own enumerable properties of an object, and return an object with properties… [more](https://github.com/jonschlinkert/for-own)
+* [is-plain-object](https://github.com/jonschlinkert/is-plain-object): Returns true if an object was created by the `Object` constructor.
+* [isobject](https://github.com/jonschlinkert/isobject): Returns true if the value is an object and not an array or null.
+
+## Running tests
+
+Install dev dependencies:
+
+```sh
+$ npm i -d && npm test
+```
+
+## Contributing
+
+Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/is-equal-shallow/issues/new)
+
+## Author
+
+**Jon Schlinkert**
+
++ [github/jonschlinkert](https://github.com/jonschlinkert)
++ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
+
+## License
+
+Copyright © 2015 Jon Schlinkert
+Released under the MIT license.
+
+***
+
+_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 22, 2015._
\ No newline at end of file
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..1006eef
--- /dev/null
+++ b/index.js
@@ -0,0 +1,27 @@
+/*!
+ * is-equal-shallow <https://github.com/jonschlinkert/is-equal-shallow>
+ *
+ * Copyright (c) 2015, Jon Schlinkert.
+ * Licensed under the MIT License.
+ */
+
+'use strict';
+
+var isPrimitive = require('is-primitive');
+
+module.exports = function isEqual(a, b) {
+  if (!a && !b) { return true; }
+  if (!a && b || a && !b) { return false; }
+
+  var numKeysA = 0, numKeysB = 0, key;
+  for (key in b) {
+    numKeysB++;
+    if (!isPrimitive(b[key]) || !a.hasOwnProperty(key) || (a[key] !== b[key])) {
+      return false;
+    }
+  }
+  for (key in a) {
+    numKeysA++;
+  }
+  return numKeysA === numKeysB;
+};
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..e35a8f5
--- /dev/null
+++ b/package.json
@@ -0,0 +1,54 @@
+{
+  "name": "is-equal-shallow",
+  "description": "Does a shallow comparison of two objects, returning false if the keys or values differ.",
+  "version": "0.1.3",
+  "homepage": "https://github.com/jonschlinkert/is-equal-shallow",
+  "author": {
+    "name": "Jon Schlinkert",
+    "url": "https://github.com/jonschlinkert"
+  },
+  "repository": {
+    "type": "git",
+    "url": "git://github.com/jonschlinkert/is-equal-shallow.git"
+  },
+  "bugs": {
+    "url": "https://github.com/jonschlinkert/is-equal-shallow/issues"
+  },
+  "license": "MIT",
+  "files": [
+    "index.js"
+  ],
+  "main": "index.js",
+  "engines": {
+    "node": ">=0.10.0"
+  },
+  "scripts": {
+    "test": "mocha"
+  },
+  "dependencies": {
+    "is-primitive": "^2.0.0"
+  },
+  "devDependencies": {
+    "mocha": "*",
+    "should": "*"
+  },
+  "keywords": [
+    "compare",
+    "comparison",
+    "equal",
+    "equals",
+    "is",
+    "is-equal",
+    "key",
+    "object",
+    "same",
+    "shallow",
+    "value"
+  ],
+  "verbiage": {
+    "related": {
+      "description": "Other object utils:",
+      "list": ["is-plain-object", "isobject", "for-in", "for-own", "clone-deep"]
+    }
+  }
+}
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..92e1d9a
--- /dev/null
+++ b/test.js
@@ -0,0 +1,38 @@
+/*!
+ * is-equal-shallow <https://github.com/jonschlinkert/is-equal-shallow>
+ *
+ * Copyright (c) 2015, Jon Schlinkert.
+ * Licensed under the MIT License.
+ */
+
+'use strict';
+
+/* deps: mocha */
+var assert = require('assert');
+var should = require('should');
+var equals = require('./');
+
+describe('equals', function () {
+  it('should return true when keys and values are the same:', function () {
+    equals({a: true, b: true}, {a: true, b: true}).should.be.true;
+  });
+
+  it('should return false when keys are different:', function () {
+    equals({a: true, b: false}, {c: false, b: false}).should.be.false;
+  });
+
+  it('should return false when values are different:', function () {
+    equals({a: true, b: false}, {a: false, b: false}).should.be.false;
+    equals({a: true, b: true}, {a: true, b: 'true'}).should.be.false;
+  });
+
+  it('should return false when a value is not a primitive:', function () {
+    equals({ b: {}}, { b: {}}).should.be.false;
+    equals({ b: []}, { b: []}).should.be.false;
+  });
+
+  it('should return false when a value is present in one object but not the other', function () {
+    equals({a: true, b: true, c: true}, {a: true, b: true}).should.be.false;
+    equals({a: true, b: true}, {a: true, b: true, c: true}).should.be.false;
+  });
+});

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



More information about the Pkg-javascript-commits mailing list