[Pkg-javascript-commits] [node-define-property] 01/06: Import Upstream version 0.2.5
Sruthi Chandran
srud-guest at moszumanska.debian.org
Sun Oct 16 17:54:08 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-define-property.
commit cb46ce69eb9e4d173b2b7ea17dd779b6b86a134b
Author: Sruthi <srud at disroot.org>
Date: Sun Oct 16 23:02:09 2016 +0530
Import Upstream version 0.2.5
---
.editorconfig | 22 +++++++++++++++++
.gitattributes | 10 ++++++++
.gitignore | 15 ++++++++++++
.jshintrc | 18 ++++++++++++++
.travis.yml | 11 +++++++++
.verb.md | 57 +++++++++++++++++++++++++++++++++++++++++++
LICENSE | 21 ++++++++++++++++
README.md | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
index.js | 31 +++++++++++++++++++++++
package.json | 51 ++++++++++++++++++++++++++++++++++++++
test.js | 53 ++++++++++++++++++++++++++++++++++++++++
11 files changed, 366 insertions(+)
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..1ff40e6
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,22 @@
+# http://editorconfig.org
+root = true
+
+[*]
+indent_style = space
+end_of_line = lf
+charset = utf-8
+indent_size = 2
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false
+insert_final_newline = false
+
+[{,test/}{actual,fixtures}/**]
+trim_trailing_whitespace = false
+insert_final_newline = false
+
+[templates/**]
+trim_trailing_whitespace = false
+insert_final_newline = false
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..660957e
--- /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
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..80a228c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,15 @@
+*.DS_Store
+*.sublime-*
+_gh_pages
+bower_components
+node_modules
+npm-debug.log
+actual
+test/actual
+temp
+tmp
+TODO.md
+vendor
+.idea
+benchmark
+coverage
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..1a2f7b9
--- /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
+}
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..0fc9381
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,11 @@
+sudo: false
+language: node_js
+node_js:
+ - "0.10"
+ - "0.12"
+ - "0.13"
+ - "iojs"
+matrix:
+ fast_finish: true
+ allow_failures:
+ - node_js: "0.13"
diff --git a/.verb.md b/.verb.md
new file mode 100644
index 0000000..de3dc50
--- /dev/null
+++ b/.verb.md
@@ -0,0 +1,57 @@
+# {%= name %} {%= badge("fury") %}
+
+> {%= description %}
+
+## Install
+{%= include("install-npm", {save: true}) %}
+
+## Usage
+
+**Params**
+
+- `obj`: The object on which to define the property.
+- `prop`: The name of the property to be defined or modified.
+- `descriptor`: The descriptor for the property being defined or modified.
+
+```js
+var define = require('{%= name %}');
+var obj = {};
+define(obj, 'foo', function(val) {
+ return val.toUpperCase();
+});
+
+console.log(obj);
+//=> {}
+
+console.log(obj.foo('bar'));
+//=> 'BAR'
+```
+
+**get/set**
+
+```js
+define(obj, 'foo', {
+ get: function() {},
+ set: function() {}
+});
+```
+
+## Related projects
+{%= related(verb.related.list, {remove: name}) %}
+
+## 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..8cac698
--- /dev/null
+++ b/README.md
@@ -0,0 +1,77 @@
+# define-property [![NPM version](https://badge.fury.io/js/define-property.svg)](http://badge.fury.io/js/define-property)
+
+> Define a non-enumerable property on an object.
+
+## Install
+
+Install with [npm](https://www.npmjs.com/)
+
+```sh
+$ npm i define-property --save
+```
+
+## Usage
+
+**Params**
+
+* `obj`: The object on which to define the property.
+* `prop`: The name of the property to be defined or modified.
+* `descriptor`: The descriptor for the property being defined or modified.
+
+```js
+var define = require('define-property');
+var obj = {};
+define(obj, 'foo', function(val) {
+ return val.toUpperCase();
+});
+
+console.log(obj);
+//=> {}
+
+console.log(obj.foo('bar'));
+//=> 'BAR'
+```
+
+**get/set**
+
+```js
+define(obj, 'foo', {
+ get: function() {},
+ set: function() {}
+});
+```
+
+## Related projects
+
+* [delegate-object](https://www.npmjs.com/package/delegate-object): Copy properties from an object to another object, where properties with function values will be… [more](https://www.npmjs.com/package/delegate-object) | [homepage](https://github.com/doowb/delegate-object)
+* [forward-object](https://www.npmjs.com/package/forward-object): Copy properties from an object to another object, where properties with function values will be… [more](https://www.npmjs.com/package/forward-object) | [homepage](https://github.com/doowb/forward-object)
+* [mixin-deep](https://www.npmjs.com/package/mixin-deep): Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone. | [homepage](https://github.com/jonschlinkert/mixin-deep)
+* [mixin-object](https://www.npmjs.com/package/mixin-object): Mixin the own and inherited properties of other objects onto the first object. Pass an… [more](https://www.npmjs.com/package/mixin-object) | [homepage](https://github.com/jonschlinkert/mixin-object)
+
+## 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/define-property/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 August 31, 2015._
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..3e0e5e1
--- /dev/null
+++ b/index.js
@@ -0,0 +1,31 @@
+/*!
+ * define-property <https://github.com/jonschlinkert/define-property>
+ *
+ * Copyright (c) 2015, Jon Schlinkert.
+ * Licensed under the MIT License.
+ */
+
+'use strict';
+
+var isDescriptor = require('is-descriptor');
+
+module.exports = function defineProperty(obj, prop, val) {
+ if (typeof obj !== 'object' && typeof obj !== 'function') {
+ throw new TypeError('expected an object or function.');
+ }
+
+ if (typeof prop !== 'string') {
+ throw new TypeError('expected `prop` to be a string.');
+ }
+
+ if (isDescriptor(val) && ('set' in val || 'get' in val)) {
+ return Object.defineProperty(obj, prop, val);
+ }
+
+ return Object.defineProperty(obj, prop, {
+ configurable: true,
+ enumerable: false,
+ writable: true,
+ value: val
+ });
+};
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..43561bf
--- /dev/null
+++ b/package.json
@@ -0,0 +1,51 @@
+{
+ "name": "define-property",
+ "description": "Define a non-enumerable property on an object.",
+ "version": "0.2.5",
+ "homepage": "https://github.com/jonschlinkert/define-property",
+ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
+ "repository": "jonschlinkert/define-property",
+ "bugs": {
+ "url": "https://github.com/jonschlinkert/define-property/issues"
+ },
+ "license": "MIT",
+ "files": [
+ "index.js"
+ ],
+ "main": "index.js",
+ "engines": {
+ "node": ">=0.10.0"
+ },
+ "scripts": {
+ "test": "mocha"
+ },
+ "devDependencies": {
+ "mocha": "*",
+ "should": "^7.0.4"
+ },
+ "keywords": [
+ "define",
+ "define-property",
+ "enumerable",
+ "key",
+ "non",
+ "non-enumerable",
+ "object",
+ "prop",
+ "property",
+ "value"
+ ],
+ "verb": {
+ "related": {
+ "list": [
+ "mixin-deep",
+ "mixin-object",
+ "delegate-object",
+ "forward-object"
+ ]
+ }
+ },
+ "dependencies": {
+ "is-descriptor": "^0.1.0"
+ }
+}
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..7109ad5
--- /dev/null
+++ b/test.js
@@ -0,0 +1,53 @@
+'use strict';
+
+/* deps: mocha */
+var assert = require('assert');
+var should = require('should');
+var define = require('./');
+
+describe('define', function () {
+ it('should define a property and make it non-enumerable:', function () {
+ var obj = {};
+ define(obj, 'foo', function(val) {
+ return val.toUpperCase();
+ });
+
+ assert.deepEqual(obj, {});
+ assert.equal(obj.foo('bar'), 'BAR');
+ });
+
+ it('should allow any arbitrary value to be assigned:', function () {
+ var obj = {};
+ define(obj, 'foo', null);
+ define(obj, 'bar');
+ define(obj, 'baz', {});
+ assert.equal(obj.foo, null);
+ assert.equal(obj.bar, undefined);
+ assert.deepEqual(obj.baz, {});
+ });
+
+ it('should define a property with accessor descriptors:', function () {
+ var obj = {bar: 'baz'};
+ define(obj, 'foo', {
+ configurable: true,
+ get: function() {
+ return this._val;
+ },
+ set: function(key) {
+ define(this, '_val', this[key]);
+ }
+ });
+ obj.foo = 'bar';
+ assert.equal(obj.foo, 'baz');
+ });
+
+ it('should throw an error when invalid args are passed:', function () {
+ (function () {
+ define();
+ }).should.throw('expected an object or function.');
+
+ (function () {
+ define({});
+ }).should.throw('expected `prop` to be a string.');
+ });
+});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-define-property.git
More information about the Pkg-javascript-commits
mailing list