stuff
This commit is contained in:
15
buildfiles/node_modules/proto-list/LICENSE
generated
vendored
Normal file
15
buildfiles/node_modules/proto-list/LICENSE
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
3
buildfiles/node_modules/proto-list/README.md
generated
vendored
Normal file
3
buildfiles/node_modules/proto-list/README.md
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
A list of objects, bound by their prototype chain.
|
||||
|
||||
Used in npm's config stuff.
|
51
buildfiles/node_modules/proto-list/package.json
generated
vendored
Normal file
51
buildfiles/node_modules/proto-list/package.json
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
{
|
||||
"_from": "proto-list@~1.2.1",
|
||||
"_id": "proto-list@1.2.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk=",
|
||||
"_location": "/proto-list",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "proto-list@~1.2.1",
|
||||
"name": "proto-list",
|
||||
"escapedName": "proto-list",
|
||||
"rawSpec": "~1.2.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~1.2.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/config-chain"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz",
|
||||
"_shasum": "212d5bfe1318306a420f6402b8e26ff39647a849",
|
||||
"_spec": "proto-list@~1.2.1",
|
||||
"_where": "/home/shihaam/www/freezer.shihaam.me/node_modules/config-chain",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
"url": "http://blog.izs.me/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/proto-list/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "A utility for managing a prototype chain",
|
||||
"devDependencies": {
|
||||
"tap": "0"
|
||||
},
|
||||
"homepage": "https://github.com/isaacs/proto-list#readme",
|
||||
"license": "ISC",
|
||||
"main": "./proto-list.js",
|
||||
"name": "proto-list",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/isaacs/proto-list.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"version": "1.2.4"
|
||||
}
|
88
buildfiles/node_modules/proto-list/proto-list.js
generated
vendored
Normal file
88
buildfiles/node_modules/proto-list/proto-list.js
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
|
||||
module.exports = ProtoList
|
||||
|
||||
function setProto(obj, proto) {
|
||||
if (typeof Object.setPrototypeOf === "function")
|
||||
return Object.setPrototypeOf(obj, proto)
|
||||
else
|
||||
obj.__proto__ = proto
|
||||
}
|
||||
|
||||
function ProtoList () {
|
||||
this.list = []
|
||||
var root = null
|
||||
Object.defineProperty(this, 'root', {
|
||||
get: function () { return root },
|
||||
set: function (r) {
|
||||
root = r
|
||||
if (this.list.length) {
|
||||
setProto(this.list[this.list.length - 1], r)
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
})
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
, get store () {
|
||||
return this.list[0]
|
||||
}
|
||||
, push : function (obj) {
|
||||
if (typeof obj !== "object") obj = {valueOf:obj}
|
||||
if (this.list.length >= 1) {
|
||||
setProto(this.list[this.list.length - 1], obj)
|
||||
}
|
||||
setProto(obj, this.root)
|
||||
return this.list.push(obj)
|
||||
}
|
||||
, pop : function () {
|
||||
if (this.list.length >= 2) {
|
||||
setProto(this.list[this.list.length - 2], this.root)
|
||||
}
|
||||
return this.list.pop()
|
||||
}
|
||||
, unshift : function (obj) {
|
||||
setProto(obj, this.list[0] || this.root)
|
||||
return this.list.unshift(obj)
|
||||
}
|
||||
, shift : function () {
|
||||
if (this.list.length === 1) {
|
||||
setProto(this.list[0], this.root)
|
||||
}
|
||||
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 () {
|
||||
// handle injections
|
||||
var ret = this.list.splice.apply(this.list, arguments)
|
||||
for (var i = 0, l = this.list.length; i < l; i++) {
|
||||
setProto(this.list[i], this.list[i + 1] || this.root)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
}
|
61
buildfiles/node_modules/proto-list/test/basic.js
generated
vendored
Normal file
61
buildfiles/node_modules/proto-list/test/basic.js
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
var tap = require("tap")
|
||||
, test = tap.test
|
||||
, ProtoList = require("../proto-list.js")
|
||||
|
||||
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)
|
||||
|
||||
|
||||
p.unshift({foo:"blo", bar:"rab"})
|
||||
p.unshift({foo:"boo"})
|
||||
t.equal(p.length, 3)
|
||||
t.equal(p.get("foo"), "boo")
|
||||
t.equal(p.get("bar"), "rab")
|
||||
|
||||
var ret = p.splice(1, 1, {bar:"bar"})
|
||||
t.same(ret, [{foo:"blo", bar:"rab"}])
|
||||
t.equal(p.get("bar"), "bar")
|
||||
|
||||
// should not inherit default object properties
|
||||
t.equal(p.get('hasOwnProperty'), undefined)
|
||||
|
||||
// unless we give it those.
|
||||
p.root = {}
|
||||
t.equal(p.get('hasOwnProperty'), {}.hasOwnProperty)
|
||||
|
||||
p.root = {default:'monkey'}
|
||||
t.equal(p.get('default'), 'monkey')
|
||||
|
||||
p.push({red:'blue'})
|
||||
p.push({red:'blue'})
|
||||
p.push({red:'blue'})
|
||||
while (p.length) {
|
||||
t.equal(p.get('default'), 'monkey')
|
||||
p.shift()
|
||||
}
|
||||
|
||||
t.end()
|
||||
})
|
Reference in New Issue
Block a user