[Pkg-javascript-commits] [node-is-plain-object] 02/07: Import Upstream version 2.0.1

Sruthi Chandran srud-guest at moszumanska.debian.org
Tue Oct 25 13:10:30 UTC 2016


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

srud-guest pushed a commit to branch master
in repository node-is-plain-object.

commit 72ac39df0e90fc6eb53a9386779bfd6119b58039
Author: Sruthi <srud at disroot.org>
Date:   Tue Oct 25 17:50:50 2016 +0530

    Import Upstream version 2.0.1
---
 .gitattributes             | 10 ++++++
 .gitignore                 | 53 +++++++++++++++++++++++++++++
 .jshintrc                  | 18 ++++++++++
 .travis.yml                |  8 +++++
 .verb.md                   | 61 +++++++++++++++++++++++++++++++++
 LICENSE                    | 21 ++++++++++++
 README.md                  | 84 ++++++++++++++++++++++++++++++++++++++++++++++
 bower.json                 | 39 +++++++++++++++++++++
 browser/is-plain-object.js |  1 +
 index.js                   | 37 ++++++++++++++++++++
 package.json               | 51 ++++++++++++++++++++++++++++
 test/browser-iframe.html   | 33 ++++++++++++++++++
 test/browser.html          | 64 +++++++++++++++++++++++++++++++++++
 test/server.js             | 34 +++++++++++++++++++
 14 files changed, 514 insertions(+)

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..92139bd
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,53 @@
+# Numerous always-ignore extensions
+*.DS_Store
+*.csv
+*.dat
+*.diff
+*.err
+*.gz
+*.log
+*.orig
+*.out
+*.pid
+*.rar
+*.rej
+*.seed
+*.swo
+*.swp
+*.vi
+*.yo-rc.json
+*.zip
+*~
+.ruby-version
+lib-cov
+npm-debug.log
+
+# Always-ignore dirs
+/bower_components/
+/node_modules/
+/temp/
+/tmp/
+/vendor/
+_gh_pages
+
+# OS or Editor folders
+*.esproj
+*.komodoproject
+.komodotools
+*.sublime-*
+._*
+.cache
+.DS_Store
+.idea
+.project
+.settings
+.tmproj
+nbproject
+Thumbs.db
+
+# grunt-html-validation
+validation-status.json
+validation-report.json
+
+# misc
+TODO.md
\ 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..f9cffe6
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,8 @@
+sudo: false
+language: node_js
+node_js:
+  - "0.10"
+  - "0.12"
+  - "iojs"
+git:
+  depth: 10
diff --git a/.verb.md b/.verb.md
new file mode 100644
index 0000000..0ff58ee
--- /dev/null
+++ b/.verb.md
@@ -0,0 +1,61 @@
+# {%= name %} {%= badge("fury") %}
+
+> {%= description %}
+
+Use [isobject](https://github.com/jonschlinkert/isobject) if you only want to check if the value is an object and not an array or null.
+
+## Install
+{%= include("install-npm", {save: true}) %}
+
+## Usage
+
+```js
+var isPlainObject = require('{%= name %}');
+```
+
+**true** when created by the `Object` constructor.
+
+```js
+isPlainObject(Object.create({}));
+//=> true
+isPlainObject(Object.create(Object.prototype));
+//=> true
+isPlainObject({foo: 'bar'});
+//=> true
+isPlainObject({});
+//=> true
+```
+
+**false** when not created by the `Object` constructor.
+
+```js
+isPlainObject(1);
+//=> false
+isPlainObject(['foo', 'bar']);
+//=> false
+isPlainObject([]);
+//=> false
+isPlainObject(new Foo);
+//=> false
+isPlainObject(null);
+//=> false
+isPlainObject(Object.create(null));
+//=> false
+```
+
+## Related projects
+{%= related(['is-plain-object', 'kind-of', 'for-own', 'extend-shallow', 'isobject', 'for-in', 'assign-deep', 'merge-deep']) %}
+
+## Running tests
+{%= include("tests") %}
+
+## Author
+{%= include("author") %}
+
+## License
+{%= copyright() %}
+{%= license() %}
+
+***
+
+{%= include("footer") %}
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..317b8ac
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014-2015, object Object.
+
+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..1847a7d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,84 @@
+# is-plain-object [![NPM version](https://badge.fury.io/js/is-plain-object.svg)](http://badge.fury.io/js/is-plain-object)
+
+> Returns true if an object was created by the `Object` constructor.
+
+Use [isobject](https://github.com/jonschlinkert/isobject) if you only want to check if the value is an object and not an array or null.
+
+## Install
+
+Install with [npm](https://www.npmjs.com/)
+
+```sh
+$ npm i is-plain-object --save
+```
+
+## Usage
+
+```js
+var isPlainObject = require('is-plain-object');
+```
+
+**true** when created by the `Object` constructor.
+
+```js
+isPlainObject(Object.create({}));
+//=> true
+isPlainObject(Object.create(Object.prototype));
+//=> true
+isPlainObject({foo: 'bar'});
+//=> true
+isPlainObject({});
+//=> true
+```
+
+**false** when not created by the `Object` constructor.
+
+```js
+isPlainObject(1);
+//=> false
+isPlainObject(['foo', 'bar']);
+//=> false
+isPlainObject([]);
+//=> false
+isPlainObject(new Foo);
+//=> false
+isPlainObject(null);
+//=> false
+isPlainObject(Object.create(null));
+//=> false
+```
+
+## Related projects
+
+* [assign-deep](https://github.com/jonschlinkert/assign-deep): Deeply assign the enumerable properties of source objects to a destination object.
+* [extend-shallow](https://github.com/jonschlinkert/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util.
+* [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)
+* [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)
+* [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.
+* [kind-of](https://github.com/jonschlinkert/kind-of): Get the native type of a value.
+* [merge-deep](https://github.com/jonschlinkert/merge-deep): Recursively merge values in a javascript object.
+
+## Running tests
+
+Install dev dependencies:
+
+```sh
+$ npm i -d && npm test
+```
+
+## 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 May 28, 2015._
diff --git a/bower.json b/bower.json
new file mode 100644
index 0000000..633b9a5
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,39 @@
+{
+  "name": "is-plain-object",
+  "description": "Returns true if an object was created by the `Object` constructor.",
+  "repository": "jonschlinkert/is-plain-object",
+  "license": "MIT",
+  "homepage": "https://github.com/jonschlinkert/is-plain-object",
+  "authors": [
+    "Jon Schlinkert (https://github.com/jonschlinkert)"
+  ],
+  "main": [
+    "index.js"
+  ],
+  "dependencies": {
+    "isobject": "^1.0.0"
+  },
+  "devDependencies": {
+    "browserify": "*",
+    "chai": "*",
+    "mocha": "*",
+    "mocha-phantomjs": "*",
+    "phantomjs": "*",
+    "uglify-js": "*"
+  },
+  "keywords": [
+    "object",
+    "is",
+    "is-object",
+    "isobject",
+    "plain",
+    "value",
+    "type",
+    "kind",
+    "kind-of",
+    "typeof",
+    "javascript",
+    "check",
+    "type"
+  ]
+}
\ No newline at end of file
diff --git a/browser/is-plain-object.js b/browser/is-plain-object.js
new file mode 100644
index 0000000..535f642
--- /dev/null
+++ b/browser/is-plain-object.js
@@ -0,0 +1 @@
+!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.isPlainObject=e()}}(function(){return function e(t,r,n){function o(f,u){if(!r[f]){if(!t[f]){var c="function"==typeof require&&require;if(!u&&c)return c(f,!0);if(i)return i(f,!0);var p=new Error("Cannot find module '"+f+"'");thr [...]
\ No newline at end of file
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..69b95c1
--- /dev/null
+++ b/index.js
@@ -0,0 +1,37 @@
+/*!
+ * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
+ *
+ * Copyright (c) 2014-2015, Jon Schlinkert.
+ * Licensed under the MIT License.
+ */
+
+'use strict';
+
+var isObject = require('isobject');
+
+function isObjectObject(o) {
+  return isObject(o) === true
+    && Object.prototype.toString.call(o) === '[object Object]';
+}
+
+module.exports = function isPlainObject(o) {
+  var ctor,prot;
+  
+  if (isObjectObject(o) === false) return false;
+  
+  // If has modified constructor
+  ctor = o.constructor;
+  if (typeof ctor !== 'function') return false;
+  
+  // If has modified prototype
+  prot = ctor.prototype;
+  if (isObjectObject(prot) === false) return false;
+  
+  // If constructor does not have an Object-specific method
+  if (prot.hasOwnProperty('isPrototypeOf') === false) {
+    return false;
+  }
+  
+  // Most likely a plain Object
+  return true;
+};
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..f86398f
--- /dev/null
+++ b/package.json
@@ -0,0 +1,51 @@
+{
+  "name": "is-plain-object",
+  "description": "Returns true if an object was created by the `Object` constructor.",
+  "version": "2.0.1",
+  "homepage": "https://github.com/jonschlinkert/is-plain-object",
+  "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
+  "repository": "jonschlinkert/is-plain-object",
+  "bugs": {
+    "url": "https://github.com/jonschlinkert/is-plain-object/issues"
+  },
+  "license": "MIT",
+  "files": [
+    "index.js"
+  ],
+  "main": "index.js",
+  "engines": {
+    "node": ">=0.10.0"
+  },
+  "scripts": {
+    "browserify": "browserify index.js --standalone isPlainObject | uglifyjs --compress --mangle -o browser/is-plain-object.js",
+    "test_browser": "mocha-phantomjs test/browser.html",
+    "test_node": "mocha",
+    "test": "npm run test_node && npm run browserify && npm run test_browser"
+  },
+  "dependencies": {
+    "isobject": "^1.0.0"
+  },
+  "devDependencies": {
+    "browserify": "*",
+    "chai": "*",
+    "mocha": "*",
+    "mocha-phantomjs": "*",
+    "phantomjs": "*",
+    "uglify-js": "*"
+  },
+  "keywords": [
+    "object",
+    "is",
+    "is-object",
+    "isobject",
+    "plain",
+    "value",
+    "type",
+    "kind",
+    "kind-of",
+    "typeof",
+    "javascript",
+    "check",
+    "type"
+  ]
+}
diff --git a/test/browser-iframe.html b/test/browser-iframe.html
new file mode 100644
index 0000000..b6bfbad
--- /dev/null
+++ b/test/browser-iframe.html
@@ -0,0 +1,33 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Cross-Realm isPlainObject()</title>
+<script>
+
+function Foo() {this.abc = {};};
+
+// Should return true with isPlainObject()
+var trues = [
+  Object.create({}),
+  Object.create(Object.prototype),
+  {foo: 'bar'},
+  {}
+];
+
+// Should return false with isPlainObject()
+var falses = [
+  /foo/,
+  function() {},
+  1,
+  ['foo', 'bar'],
+  [],
+  new Foo,
+  null,
+  Object.create(null)
+];
+
+</script>
+</head>
+<body></body>
+</html>
diff --git a/test/browser.html b/test/browser.html
new file mode 100644
index 0000000..4dcdf41
--- /dev/null
+++ b/test/browser.html
@@ -0,0 +1,64 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Cross-Realm isPlainObject()</title>
+<script src="../browser/is-plain-object.js"></script>
+<script src="../node_modules/chai/chai.js"></script>
+<script src="../node_modules/mocha/mocha.js"></script>
+<script>mocha.setup('bdd'); expect=chai.expect</script>
+<link rel="stylesheet" href="../node_modules/mocha/mocha.css"/>
+</head>
+<body>
+<div id="mocha"></div>
+<script>
+
+var iframe,iframeWindow;
+var testArea = document.getElementById('mocha');
+
+describe('Cross-Realm Browser Tests', function() {
+  before( function(done) {
+    iframe = document.createElement('iframe');
+    iframe.src = 'browser-iframe.html';
+    iframe.onload = function() {
+      iframeWindow = this.contentWindow;
+      done();
+    };
+    testArea.appendChild(iframe);
+  });
+  
+  after( function(done) {
+    testArea.removeChild(iframe);
+    done();
+  });
+  
+  describe('without isPlainObject', function() {
+    it('should not work with `instanceof`', function(done) {
+      iframeWindow.trues.forEach( function(fixture) {
+        expect(fixture).to.not.be.instanceOf(Object);
+      });
+      done();
+    });
+  });
+  
+  describe('with isPlainObject', function() {
+    it('should return `true` if the object is created by the `Object` constructor.', function() {
+      iframeWindow.trues.forEach( function(fixture) {
+        expect( isPlainObject(fixture) ).to.be.true;
+      });
+    });
+    
+    it('should return `false` if the object is not created by the `Object` constructor.', function() {
+      iframeWindow.falses.forEach( function(fixture) {
+        expect( isPlainObject(fixture) ).to.be.false;
+      });
+    });
+  });
+});
+
+if (window.mochaPhantomJS) mochaPhantomJS.run();
+else mocha.run();
+
+</script>
+</body>
+</html>
diff --git a/test/server.js b/test/server.js
new file mode 100644
index 0000000..74e3dee
--- /dev/null
+++ b/test/server.js
@@ -0,0 +1,34 @@
+/*!
+ * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
+ *
+ * Copyright (c) 2014-2015, Jon Schlinkert.
+ * Licensed under the MIT License.
+ */
+
+'use strict';
+
+/* deps:mocha */
+var expect = require('chai').expect;
+var isPlainObject = require('../');
+
+describe('Same-Realm Server Tests', function() {
+  it('should return `true` if the object is created by the `Object` constructor.', function() {
+    expect( isPlainObject(Object.create({})) ).to.be.true;
+    expect( isPlainObject(Object.create(Object.prototype)) ).to.be.true;
+    expect( isPlainObject({foo: 'bar'}) ).to.be.true;
+    expect( isPlainObject({}) ).to.be.true;
+  });
+
+  it('should return `false` if the object is not created by the `Object` constructor.', function() {
+    function Foo() {this.abc = {};};
+
+    expect( isPlainObject(/foo/) ).to.be.false;
+    expect( isPlainObject(function () {}) ).to.be.false;
+    expect( isPlainObject(1) ).to.be.false;
+    expect( isPlainObject(['foo', 'bar']) ).to.be.false;
+    expect( isPlainObject([]) ).to.be.false;
+    expect( isPlainObject(new Foo) ).to.be.false;
+    expect( isPlainObject(null) ).to.be.false;
+    expect( isPlainObject(Object.create(null)) ).to.be.false;
+  });
+});

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



More information about the Pkg-javascript-commits mailing list