aboutsummaryrefslogtreecommitdiff
path: root/node_modules/prr
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/prr')
-rw-r--r--node_modules/prr/.jshintrc61
-rw-r--r--node_modules/prr/.npmignore1
-rw-r--r--node_modules/prr/.travis.yml10
-rw-r--r--node_modules/prr/LICENSE39
-rw-r--r--node_modules/prr/README.md45
-rw-r--r--node_modules/prr/package.json23
-rw-r--r--node_modules/prr/prr.js63
-rw-r--r--node_modules/prr/test.js169
8 files changed, 411 insertions, 0 deletions
diff --git a/node_modules/prr/.jshintrc b/node_modules/prr/.jshintrc
new file mode 100644
index 000000000..6a7a956c0
--- /dev/null
+++ b/node_modules/prr/.jshintrc
@@ -0,0 +1,61 @@
+{
+ "predef": [ ]
+ , "bitwise": false
+ , "camelcase": false
+ , "curly": false
+ , "eqeqeq": false
+ , "forin": false
+ , "immed": false
+ , "latedef": false
+ , "newcap": true
+ , "noarg": true
+ , "noempty": true
+ , "nonew": true
+ , "plusplus": false
+ , "quotmark": true
+ , "regexp": false
+ , "undef": true
+ , "unused": true
+ , "strict": false
+ , "trailing": true
+ , "maxlen": 120
+ , "asi": true
+ , "boss": true
+ , "debug": true
+ , "eqnull": true
+ , "es5": true
+ , "esnext": true
+ , "evil": true
+ , "expr": true
+ , "funcscope": false
+ , "globalstrict": false
+ , "iterator": false
+ , "lastsemic": true
+ , "laxbreak": true
+ , "laxcomma": true
+ , "loopfunc": true
+ , "multistr": false
+ , "onecase": false
+ , "proto": false
+ , "regexdash": false
+ , "scripturl": true
+ , "smarttabs": false
+ , "shadow": false
+ , "sub": true
+ , "supernew": false
+ , "validthis": true
+ , "browser": true
+ , "couch": false
+ , "devel": false
+ , "dojo": false
+ , "mootools": false
+ , "node": true
+ , "nonstandard": true
+ , "prototypejs": false
+ , "rhino": false
+ , "worker": true
+ , "wsh": false
+ , "nomen": false
+ , "onevar": true
+ , "passfail": false
+} \ No newline at end of file
diff --git a/node_modules/prr/.npmignore b/node_modules/prr/.npmignore
new file mode 100644
index 000000000..b512c09d4
--- /dev/null
+++ b/node_modules/prr/.npmignore
@@ -0,0 +1 @@
+node_modules \ No newline at end of file
diff --git a/node_modules/prr/.travis.yml b/node_modules/prr/.travis.yml
new file mode 100644
index 000000000..fe3f4eb15
--- /dev/null
+++ b/node_modules/prr/.travis.yml
@@ -0,0 +1,10 @@
+language: node_js
+node_js:
+ - 0.8
+ - "0.10"
+branches:
+ only:
+ - master
+notifications:
+ email:
+ - rod@vagg.org
diff --git a/node_modules/prr/LICENSE b/node_modules/prr/LICENSE
new file mode 100644
index 000000000..f6a0029de
--- /dev/null
+++ b/node_modules/prr/LICENSE
@@ -0,0 +1,39 @@
+Copyright 2013, Rod Vagg (the "Original Author")
+All rights reserved.
+
+MIT +no-false-attribs License
+
+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.
+
+Distributions of all or part of the Software intended to be used
+by the recipients as they would use the unmodified Software,
+containing modifications that substantially alter, remove, or
+disable functionality of the Software, outside of the documented
+configuration mechanisms provided by the Software, shall be
+modified such that the Original Author's bug reporting email
+addresses and urls are either replaced with the contact information
+of the parties responsible for the changes, or removed entirely.
+
+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.
+
+
+Except where noted, this license applies to any and all software
+programs and associated documentation files created by the
+Original Author, when distributed with the Software. \ No newline at end of file
diff --git a/node_modules/prr/README.md b/node_modules/prr/README.md
new file mode 100644
index 000000000..3e709e3bd
--- /dev/null
+++ b/node_modules/prr/README.md
@@ -0,0 +1,45 @@
+# prr [![Build Status](https://secure.travis-ci.org/rvagg/prr.png)](http://travis-ci.org/rvagg/prr)
+
+An sensible alternative to `Object.defineProperty()`. Available in npm and Ender as **prr**.
+
+## Usage
+
+Set the property `'foo'` (`obj.foo`) to have the value `'bar'` with default options (*enumerable, configurable and writable are all false*):
+
+```js
+prr(obj, 'foo', 'bar')
+```
+
+Adjust the default options:
+
+```js
+prr(obj, 'foo', 'bar', { enumerable: true, writable: true })
+```
+
+Do the same operation for multiple properties:
+
+```js
+prr(obj, { one: 'one', two: 'two' })
+// or with options:
+prr(obj, { one: 'one', two: 'two' }, { enumerable: true, writable: true })
+```
+
+But obviously, having to write out the full options object makes it nearly as bad as the original `Object.defineProperty()` so we can **simplify**.
+
+As an alternative method we can use an options string where each character represents a option: `'e'=='enumerable'`, `'c'=='configurable'` and `'w'=='writable'`:
+
+```js
+prr(obj, 'foo', 'bar', 'ew') // enumerable and writable but not configurable
+// muliple properties:
+prr(obj, { one: 'one', two: 'two' }, 'ewc') // configurable too
+```
+
+## Where can I use it?
+
+Anywhere! For pre-ES5 environments *prr* will simply fall-back to an `object[property] = value` so you can get close to what you want.
+
+*prr* is Ender-compatible so you can include it in your Ender build and `$.prr(...)` or `var prr = require('prr'); prr(...)`.
+
+## Licence
+
+prr is Copyright (c) 2013 Rod Vagg [@rvagg](https://twitter.com/rvagg) and licensed under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details. \ No newline at end of file
diff --git a/node_modules/prr/package.json b/node_modules/prr/package.json
new file mode 100644
index 000000000..0adab2b04
--- /dev/null
+++ b/node_modules/prr/package.json
@@ -0,0 +1,23 @@
+{
+ "name" : "prr"
+ , "description" : "A better Object.defineProperty()"
+ , "version" : "0.0.0"
+ , "homepage" : "https://github.com/rvagg/prr"
+ , "authors" : [
+ "Rod Vagg <rod@vagg.org> (https://github.com/rvagg)"
+ ]
+ , "keywords" : [ "property", "properties", "defineProperty", "ender" ]
+ , "main" : "./prr.js"
+ , "repository" : {
+ "type" : "git"
+ , "url" : "https://github.com/rvagg/prr.git"
+ }
+ , "dependencies" : {}
+ , "devDependencies" : {
+ "tap" : "*"
+ }
+ , "scripts": {
+ "test" : "node ./test.js"
+ }
+ , "license" : "MIT"
+} \ No newline at end of file
diff --git a/node_modules/prr/prr.js b/node_modules/prr/prr.js
new file mode 100644
index 000000000..94f58628b
--- /dev/null
+++ b/node_modules/prr/prr.js
@@ -0,0 +1,63 @@
+/*!
+ * prr
+ * (c) 2013 Rod Vagg <rod@vagg.org>
+ * https://github.com/rvagg/prr
+ * License: MIT
+ */
+
+(function (name, context, definition) {
+ if (typeof module != 'undefined' && module.exports)
+ module.exports = definition()
+ else
+ context[name] = definition()
+})('prr', this, function() {
+
+ var setProperty = typeof Object.defineProperty == 'function'
+ ? function (obj, key, options) {
+ Object.defineProperty(obj, key, options)
+ return obj
+ }
+ : function (obj, key, options) { // < es5
+ obj[key] = options.value
+ return obj
+ }
+
+ , makeOptions = function (value, options) {
+ var oo = typeof options == 'object'
+ , os = !oo && typeof options == 'string'
+ , op = function (p) {
+ return oo
+ ? !!options[p]
+ : os
+ ? options.indexOf(p[0]) > -1
+ : false
+ }
+
+ return {
+ enumerable : op('enumerable')
+ , configurable : op('configurable')
+ , writable : op('writable')
+ , value : value
+ }
+ }
+
+ , prr = function (obj, key, value, options) {
+ var k
+
+ options = makeOptions(value, options)
+
+ if (typeof key == 'object') {
+ for (k in key) {
+ if (Object.hasOwnProperty.call(key, k)) {
+ options.value = key[k]
+ setProperty(obj, k, options)
+ }
+ }
+ return obj
+ }
+
+ return setProperty(obj, key, options)
+ }
+
+ return prr
+}) \ No newline at end of file
diff --git a/node_modules/prr/test.js b/node_modules/prr/test.js
new file mode 100644
index 000000000..5222e3073
--- /dev/null
+++ b/node_modules/prr/test.js
@@ -0,0 +1,169 @@
+const test = require('tap').test
+ , prr = require('./')
+
+test('test prr(o, key, value) form', function (t) {
+ t.plan(2)
+
+ var o = {}
+ prr(o, 'foo', 'bar')
+ t.equal(o.foo, 'bar', 'correct value')
+ t.deepEqual(
+ Object.getOwnPropertyDescriptor(o, 'foo')
+ , {
+ enumerable : false
+ , configurable : false
+ , writable : false
+ , value : 'bar'
+ }
+ , 'correct property descriptor'
+ )
+ t.end()
+})
+
+test('test prr(o, { key: value }) form', function (t) {
+ t.plan(2)
+
+ var o = {}
+ prr(o, { foo: 'bar' })
+
+ t.equal(o.foo, 'bar', 'correct value')
+ t.deepEqual(
+ Object.getOwnPropertyDescriptor(o, 'foo')
+ , {
+ enumerable : false
+ , configurable : false
+ , writable : false
+ , value : 'bar'
+ }
+ , 'correct property descriptor'
+ )
+ t.end()
+})
+
+test('test multiple key:value pairs', function (t) {
+ var o = { foo: 'bar' }
+
+ prr(o, { one: 'ONE', two: 'TWO', obj: { o: 'o' }})
+
+ t.deepEqual(o, { foo: 'bar' }, 'properties are not enumerable')
+ t.equal(o.one, 'ONE', 'correctly set property')
+ t.equal(o.two, 'TWO', 'correctly set property')
+ t.deepEqual(o.obj, { o: 'o' }, 'correctly set property')
+
+ ;[ 'one', 'two', 'obj' ].forEach(function (p) {
+ t.deepEqual(
+ Object.getOwnPropertyDescriptor(o, p)
+ , {
+ enumerable : false
+ , configurable : false
+ , writable : false
+ , value : p == 'obj' ? { o: 'o' } : p.toUpperCase()
+ }
+ , 'correct property descriptor'
+ )
+ })
+
+ t.end()
+})
+
+test('test descriptor options', function (t) {
+ var o = {}
+
+ prr(o, 'foo', 'bar', {
+ enumerable : true
+ , configurable : false
+ })
+ t.equal(o.foo, 'bar', 'correct value')
+ t.deepEqual(
+ Object.getOwnPropertyDescriptor(o, 'foo')
+ , {
+ enumerable : true
+ , configurable : false
+ , writable : false
+ , value : 'bar'
+ }
+ , 'correct property descriptor'
+ )
+
+ prr(o, 'foo2', 'bar2', {
+ enumerable : true
+ , configurable : true
+ , writable : false
+ })
+ t.equal(o.foo2, 'bar2', 'correct value')
+ t.deepEqual(
+ Object.getOwnPropertyDescriptor(o, 'foo2')
+ , {
+ enumerable : true
+ , configurable : true
+ , writable : false
+ , value : 'bar2'
+ }
+ , 'correct property descriptor'
+ )
+
+ prr(o, 'foo3', 'bar3', {
+ enumerable : true
+ , configurable : true
+ , writable : true
+ })
+ t.equal(o.foo3, 'bar3', 'correct value')
+ t.deepEqual(
+ Object.getOwnPropertyDescriptor(o, 'foo3')
+ , {
+ enumerable : true
+ , configurable : true
+ , writable : true
+ , value : 'bar3'
+ }
+ , 'correct property descriptor'
+ )
+
+ t.end()
+})
+
+
+test('test descriptor options, string form', function (t) {
+ var o = {}
+
+ prr(o, 'foo', 'bar', 'e')
+ t.equal(o.foo, 'bar', 'correct value')
+ t.deepEqual(
+ Object.getOwnPropertyDescriptor(o, 'foo')
+ , {
+ enumerable : true
+ , configurable : false
+ , writable : false
+ , value : 'bar'
+ }
+ , 'correct property descriptor'
+ )
+
+ prr(o, 'foo2', 'bar2', 'ec')
+ t.equal(o.foo2, 'bar2', 'correct value')
+ t.deepEqual(
+ Object.getOwnPropertyDescriptor(o, 'foo2')
+ , {
+ enumerable : true
+ , configurable : true
+ , writable : false
+ , value : 'bar2'
+ }
+ , 'correct property descriptor'
+ )
+
+ prr(o, 'foo3', 'bar3', 'ecw')
+ t.equal(o.foo3, 'bar3', 'correct value')
+ t.deepEqual(
+ Object.getOwnPropertyDescriptor(o, 'foo3')
+ , {
+ enumerable : true
+ , configurable : true
+ , writable : true
+ , value : 'bar3'
+ }
+ , 'correct property descriptor'
+ )
+
+ t.end()
+})