Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add proto-list as dep and submodule

  • Loading branch information...
commit ba1830fdbbc0fba6a0fff79ddb1d3b7ebf460360 1 parent 7073b41
@isaacs isaacs authored
View
3  .gitmodules
@@ -22,3 +22,6 @@
[submodule "node_modules/rimraf"]
path = node_modules/rimraf
url = https://github.com/isaacs/rimraf.git
+[submodule "node_modules/proto-list"]
+ path = node_modules/proto-list
+ url = https://github.com/isaacs/proto-list.git
View
2  lib/utils/ini.js
@@ -35,7 +35,7 @@ var fs = require("graceful-fs")
, log = require("./log.js")
, ini = require("./ini-parser.js")
, base64 = require("./base64.js")
- , ProtoList = require("./proto-list.js")
+ , ProtoList = require("proto-list")
, defaultConfig
, configList = new ProtoList()
, configDefs = require("./config-defs.js")
View
92 lib/utils/proto-list.js
@@ -1,92 +0,0 @@
-
-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 assert = require("assert")
- , util = require("util")
-
-util.debug("testing")
-var p = new ProtoList
-p.push({foo:"bar"})
-p.push({})
-p.set("foo", "baz")
-assert.equal(p.get("foo"), "baz")
-
-var p = new ProtoList
-p.push({foo:"bar"})
-p.set("foo", "baz")
-assert.equal(p.get("foo"), "baz")
-assert.equal(p.length, 1)
-p.pop()
-assert.equal(p.length, 0)
-p.set("foo", "asdf")
-assert.equal(p.length, 1)
-assert.equal(p.get("foo"), "asdf")
-p.push({bar:"baz"})
-assert.equal(p.length, 2)
-assert.equal(p.get("foo"), "asdf")
-p.shift()
-assert.equal(p.length, 1)
-assert.equal(p.get("foo"), undefined)
-
-
-
-util.debug("ok")
-}
1  node_modules/proto-list
@@ -0,0 +1 @@
+Subproject commit e1f8f2578d33eea5b09346bfde163badd7e61c90
View
5 package.json
@@ -31,6 +31,7 @@
, "minimatch" : "0"
, "nopt" : "1"
, "node-uuid" : "1.2"
+ , "proto-list": "1"
, "rimraf" : "1" }
, "bundleDependencies" :
[ "slide"
@@ -39,7 +40,9 @@
, "graceful-fs"
, "minimatch"
, "nopt"
- , "node-uuid" ]
+ , "node-uuid"
+ , "rimraf"
+ , "proto-list" ]
, "devDependencies" : { "ronn" : "" }
, "engines" : { "node" : "0.4 || 0.5", "npm" : "1" }
, "scripts" : { "test" : "./test/run.sh"
Please sign in to comment.
Something went wrong with that request. Please try again.