aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/proto-list
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2011-11-21 09:48:45 -0800
committerRyan Dahl <ry@tinyclouds.org>2011-11-21 10:50:52 -0800
commitb488be127a8cf1e59eb257db3f8eaf6efdb0f275 (patch)
tree83436f4f84b9651ea66c3a0d304050252916c149 /deps/npm/node_modules/proto-list
parent05de01d707cd9a80f34da23445f507f5f2e2c277 (diff)
downloadandroid-node-v8-b488be127a8cf1e59eb257db3f8eaf6efdb0f275.tar.gz
android-node-v8-b488be127a8cf1e59eb257db3f8eaf6efdb0f275.tar.bz2
android-node-v8-b488be127a8cf1e59eb257db3f8eaf6efdb0f275.zip
Include NPM, update .pkg to install it.
.msi update coming soon.
Diffstat (limited to 'deps/npm/node_modules/proto-list')
-rw-r--r--deps/npm/node_modules/proto-list/LICENSE23
-rw-r--r--deps/npm/node_modules/proto-list/README.md3
-rw-r--r--deps/npm/node_modules/proto-list/package.json9
-rw-r--r--deps/npm/node_modules/proto-list/proto-list.js94
4 files changed, 129 insertions, 0 deletions
diff --git a/deps/npm/node_modules/proto-list/LICENSE b/deps/npm/node_modules/proto-list/LICENSE
new file mode 100644
index 0000000000..05a4010949
--- /dev/null
+++ b/deps/npm/node_modules/proto-list/LICENSE
@@ -0,0 +1,23 @@
+Copyright 2009, 2010, 2011 Isaac Z. Schlueter.
+All rights reserved.
+
+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/deps/npm/node_modules/proto-list/README.md b/deps/npm/node_modules/proto-list/README.md
new file mode 100644
index 0000000000..43cfa35893
--- /dev/null
+++ b/deps/npm/node_modules/proto-list/README.md
@@ -0,0 +1,3 @@
+A list of objects, bound by their prototype chain.
+
+Used in npm's config stuff.
diff --git a/deps/npm/node_modules/proto-list/package.json b/deps/npm/node_modules/proto-list/package.json
new file mode 100644
index 0000000000..5cab34befe
--- /dev/null
+++ b/deps/npm/node_modules/proto-list/package.json
@@ -0,0 +1,9 @@
+{ "name" : "proto-list"
+, "version" : "1.0.0"
+, "description" : "A utility for managing a prototype chain"
+, "main" : "./proto-list.js"
+, "author" : "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)"
+, "scripts" : { "test" : "node proto-list.js" }
+, "repository": { "type": "git", "url": "https://github.com/isaacs/proto-list" }
+, "license": { "type": "MIT", "url": "https://github.com/isaacs/proto-list/blob/master/LICENSE" }
+, "devDependencies" : { "tap" : "0" } }
diff --git a/deps/npm/node_modules/proto-list/proto-list.js b/deps/npm/node_modules/proto-list/proto-list.js
new file mode 100644
index 0000000000..759d827382
--- /dev/null
+++ b/deps/npm/node_modules/proto-list/proto-list.js
@@ -0,0 +1,94 @@
+
+module.exports = ProtoList
+
+function ProtoList () { this.list = [] }
+ProtoList.prototype =
+ { get length () { return this.list.length }
+ , get keys () {
+ var k = []
+ for (var i in this.list[0]) k.push(i)
+ return k
+ }
+ , get snapshot () {
+ var o = {}
+ this.keys.forEach(function (k) { o[k] = this.get(k) }, this)
+ return o
+ }
+ , push : function (obj) {
+ if (typeof obj !== "object") obj = {valueOf:obj}
+ if (this.list.length >= 1) {
+ this.list[this.list.length - 1].__proto__ = obj
+ }
+ obj.__proto__ = Object.prototype
+ return this.list.push(obj)
+ }
+ , pop : function () {
+ if (this.list.length >= 2) {
+ this.list[this.list.length - 2].__proto__ = Object.prototype
+ }
+ return this.list.pop()
+ }
+ , unshift : function (obj) {
+ obj.__proto__ = this.list[0] || Object.prototype
+ return this.list.unshift(obj)
+ }
+ , shift : function () {
+ if (this.list.length >= 1) {
+ this.list[0].__proto__ = Object.prototype
+ }
+ return this.list.shift()
+ }
+ , get : function (key) {
+ return this.list[0][key]
+ }
+ , set : function (key, val, save) {
+ if (!this.length) this.push({})
+ if (save && this.list[0].hasOwnProperty(key)) this.push({})
+ return this.list[0][key] = val
+ }
+ , forEach : function (fn, thisp) {
+ for (var key in this.list[0]) fn.call(thisp, key, this.list[0][key])
+ }
+ , slice : function () {
+ return this.list.slice.apply(this.list, arguments)
+ }
+ , splice : function () {
+ return this.list.splice.apply(this.list, arguments)
+ }
+ }
+
+if (module === require.main) {
+
+var tap = require("tap")
+ , test = tap.test
+
+tap.plan(1)
+
+tap.test("protoList tests", function (t) {
+ var p = new ProtoList
+ p.push({foo:"bar"})
+ p.push({})
+ p.set("foo", "baz")
+ t.equal(p.get("foo"), "baz")
+
+ var p = new ProtoList
+ p.push({foo:"bar"})
+ p.set("foo", "baz")
+ t.equal(p.get("foo"), "baz")
+ t.equal(p.length, 1)
+ p.pop()
+ t.equal(p.length, 0)
+ p.set("foo", "asdf")
+ t.equal(p.length, 1)
+ t.equal(p.get("foo"), "asdf")
+ p.push({bar:"baz"})
+ t.equal(p.length, 2)
+ t.equal(p.get("foo"), "asdf")
+ p.shift()
+ t.equal(p.length, 1)
+ t.equal(p.get("foo"), undefined)
+ t.end()
+})
+
+
+}