Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

list

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

list - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

65

index.js

@@ -1,2 +0,2 @@

function list(next_key,prev_key,list_key)
function list(prefix)
{

@@ -6,5 +6,6 @@ this.length=0;

this.tail=null;
this._next=next_key || '_$ln';
this._prev=prev_key || '_$lp';
this._list=list_key || '_$ll';
if(!prefix)prefix='_l';
this._next=prefix+'$n';
this._prev=prefix+'$p';
this._list=prefix+'$l';
}

@@ -14,2 +15,6 @@ list.prototype=

is_empty:function(){return this.length==0;},
contains:function(o)
{
return o[this._list]==this;
},
to_array:function()

@@ -26,3 +31,3 @@ {

if(index<0 || index>=this.length)
throw new Error("out of index");
throw new Error("out of index range");
for(var i=this.head;i;i=i[this._next])

@@ -38,7 +43,7 @@ {

{
this.add(o,this.head);
return this.add(o,this.head);
},
add_tail:function(o)
{
this.add(o,null);
return this.add(o,null);
},

@@ -64,6 +69,42 @@ next:function(o)

},
shift:function()
{
var a=arguments;
var l=arguments.length;
for(var i=0;i<l;i++)
this.add(arguments[i],this.head);
},
unshift:function()
{
if(this.length)
{
var r=this.head;
this.remove(r);
return r;
}
return null;
},
pop:function()
{
if(this.length)
{
var r=this.tail;
this.remove(r);
return r;
}
return null;
},
push:function()
{
var a=arguments;
var l=arguments.length;
for(var i=0;i<l;i++)
this.add(arguments[i]);
},
add:function(o,ref)
{
if(!(o instanceof Object))
throw new Error("require object");
if(o[this._next] || o[this._prev] || o[this._list])
throw new Error("object not in this list");
throw new Error("object is in list");

@@ -125,2 +166,3 @@ /*

o[this._list]=this;
return this;
},

@@ -130,3 +172,3 @@ remove:function(o)

if(o[this._list]!=this)
throw new Error("object not in this list");
throw new Error("object not in list");

@@ -144,2 +186,7 @@ if(o==this.head) this.head=o[this._next];

this.length--;
},
clear:function()
{
while(this.head)
this.remove(this.head);
}

@@ -146,0 +193,0 @@ };

12

package.json
{
"name": "list",
"version": "0.0.3",
"version": "0.0.4",
"description": "double linked list",

@@ -17,4 +17,10 @@ "main": "index.js",

],
"author": "cy2000@gmail.com",
"license": "BSD"
"author": {
"name": "cy2000@gmail.com"
},
"license": "BSD",
"readme": "# list\n\nObject double linked list for nodejs.\n\n## Getting Started\n\nInstall it in your browser:\n\n```\nnpm install list\n```\n\n## API\n\n### list.add(item,ref)\n\n### list.add_head(item)\n\n### list.add_tail(item)\n\n### list.remove(item)\n\n### list.next(item)\n\n### list.prev(item)\n\n### list.length\n\n### list.head\n\n### list.tail\n\n### list.each(iterator)\n\n### list.to_array()\n\n### list.is_empty()\n\n\n## Sample\n\n```javascript\nvar list=require('list');\nvar mylist=new list();\n\nmylist.add({name:'item1'});\nmylist.add({name:'item2'});\nmylist.add({name:'item3'});\n\nmylist.each(function(item){\n\tconsole.log(item.name);\n});\n\n\n",
"readmeFilename": "readme.md",
"_id": "list@0.0.3",
"_from": "list"
}

@@ -14,2 +14,3 @@ # list

## API
### new list(prefix)

@@ -24,2 +25,4 @@ ### list.add(item,ref)

### list.clear()
### list.next(item)

@@ -41,3 +44,12 @@

### list.contains(item)
### list.push(item)
### list.pop()
### list.shift()
### list.unshift(item)
## Sample

@@ -44,0 +56,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc