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

data-footstone

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data-footstone - npm Package Compare versions

Comparing version 0.1.17-alpha.0 to 0.1.17

162

dist_cjs/chain.js

@@ -6,5 +6,9 @@ 'use strict';

class BaseChain {
constructor() {
constructor(capacity = Number.POSITIVE_INFINITY) {
this.head = null;
this.length = 0;
Object.defineProperty(this, 'capacity', {
value: capacity,
writable: false
});
}

@@ -24,22 +28,22 @@ toArray() {

}
isEmpty() {
return !this.length;
}
isFull() {
return this.length === this.capacity;
}
}
class SingleChain extends BaseChain {
constructor(...p) {
super();
if (p.length) {
this.head = p.reduceRight((r, c, index) => {
return {
value: c,
next: r,
position: index,
};
}, null);
this.length = p.length;
}
// constructor 是实例化的过程。参数是为整个对象执行实例化时需要的内容。
// 不应该是使用时的数据。即使这个功能方便后续使用。
constructor(capacity = Number.POSITIVE_INFINITY) {
super(capacity);
this.head = null;
this.length = 0;
}
createNode(v, p) {
createNode(v, p = -1) {
return {
value: v,
next: null,
position: p,
position: p, // 负数表示不在链上
};

@@ -49,2 +53,5 @@ }

append(p) {
if (this.isFull()) {
return new Error('has full');
}
let node = this.createNode(p, this.length);

@@ -122,38 +129,2 @@ if (!this.head) {

}
// 删除此方法
// removeElement(v: T, all = false) {
// let res: B = false
// if (this.length) {
// if (this.head.value === v) {
// this.head = this.head.next
// this.length--
// res = true
// } else {
// let cur = this.head.next
// let pre = this.head
// while (cur) {
// if (cur.value === v) {
// pre.next = cur.next
// this.length--
// res = true
// if (!all) {
// break
// }
// }
// pre = cur
// cur = cur.next
// }
// }
// let cur = this.head
// let index = 0
// while (cur) {
// cur.position = index
// index++
// cur = cur.next
// }
// } else {
// res = false
// }
// return res
// }
// includes() {}

@@ -220,6 +191,6 @@ reverseSelf() {

class DoublyChain extends BaseChain {
constructor(...p) {
super();
constructor(capacity = Number.POSITIVE_INFINITY) {
super(capacity);
this.tail = null;
p.forEach(this.append, this);
// p.forEach(this.append, this)
}

@@ -235,2 +206,5 @@ createNode(v, p) {

append(v) {
if (this.isFull()) {
return new Error('has full');
}
let node = this.createNode(v, this.length);

@@ -318,33 +292,2 @@ if (this.length) {

}
// removeElement(v: T, all = false) {
// let res: B = false
// let cur = this.head
// let index = 0
// while (index < this.length) {
// if (cur.value === v) {
// if (index === 0) {
// // op this.head
// this.head = this.head.next
// this.head.prev = null
// } else if (index === this.length) {
// // op this.tail
// this.tail = this.tail.prev
// this.tail.next = null
// } else {
// // op middle
// cur.prev.next = cur.next
// cur.next.prev = cur.prev
// }
// res = true
// this.length--
// if (!all) {
// break
// }
// } else {
// index++
// }
// cur = cur.next
// }
// return res
// }
clear() {

@@ -368,8 +311,8 @@ this.head = null;

class SingleCircleChain extends SingleChain {
constructor(...p) {
super();
constructor(capacity = Number.POSITIVE_INFINITY) {
super(capacity);
this.head = null;
this.tail = null;
this.length = 0;
p.forEach(this.append, this);
// p.forEach(this.append, this)
}

@@ -395,2 +338,5 @@ toArray() {

append(v) {
if (this.isFull()) {
return new Error('has full');
}
let node = this.createNode(v, this.length);

@@ -480,5 +426,5 @@ if (this.length) {

class DoublyCircleChain extends DoublyChain {
constructor(...p) {
super();
p.forEach(this.append, this);
constructor(capacity = Number.POSITIVE_INFINITY) {
super(capacity);
// p.forEach(this.append, this)
}

@@ -494,2 +440,5 @@ createNode(v, p) {

append(p) {
if (this.isFull()) {
return new Error('has full');
}
let node = this.createNode(p, this.length);

@@ -582,32 +531,2 @@ if (this.length) {

}
// removeElement(v: T, all = false) {
// let res: B = false
// let cur = this.head
// let index = 0
// while (index < this.length) {
// if (cur.value === v) {
// if (index === 0) {
// this.head = this.head.next
// this.head.prev = this.tail
// this.tail.next = this.head
// } else if (index === this.length) {
// this.tail = this.tail.prev
// this.tail.next = this.head
// this.head.prev = this.tail
// } else {
// cur.prev.next = cur.next
// cur.next.prev = cur.prev
// }
// res = true
// this.length--
// if (!all) {
// break
// }
// } else {
// index++
// }
// cur = cur.next
// }
// return res
// }
toArray() {

@@ -637,2 +556,3 @@ let res = [];

exports.BaseChain = BaseChain;
exports.DoublyChain = DoublyChain;

@@ -639,0 +559,0 @@ exports.DoublyCircleChain = DoublyCircleChain;

@@ -5,4 +5,10 @@ 'use strict';

class BaseQueue {
constructor() {
constructor(capacity = Number.POSITIVE_INFINITY) {
this.items = [];
// this.capacity = capacity
// Object.defineProperty('')
Object.defineProperty(this, 'capacity', {
value: capacity,
writable: false
});
}

@@ -21,4 +27,6 @@ getHead() {

}
isFull() {
return this.size() === this.capacity;
}
clear() {
// return
this.items = [];

@@ -28,9 +36,21 @@ }

class Queue extends BaseQueue {
constructor(...p) {
super();
this.enqueue(...p);
// constructor(...p: T[]) {
// super()
// this.enqueue(...p)
// }
constructor(capacity = Number.POSITIVE_INFINITY) {
super(capacity);
}
enqueue(...p) {
this.items.push(...p);
return this.size();
// enqueue(...p: T[]) {
// this.items.push(...p)
// return this.size()
// }
enqueue(p) {
if (this.isFull()) {
return new Error('has full');
}
else {
this.items.push(p);
return this.size();
}
}

@@ -53,6 +73,8 @@ dequeue() {

class PriorityQueue extends BaseQueue {
constructor(defaultPriority = 0) {
super();
// this.items = []
this.defaultPriority = defaultPriority;
constructor(capacity = Number.POSITIVE_INFINITY, defaultPriority = 0) {
super(capacity);
Object.defineProperty(this, 'defaultPriority', {
value: defaultPriority,
writable: false
});
}

@@ -93,2 +115,5 @@ highestPriority() {

enqueue(element, priority = this.defaultPriority, positionFlag = true, needSetPosition = true) {
if (this.isFull()) {
return new Error('has full');
}
let len = this.size();

@@ -148,5 +173,2 @@ let node = this.createNode(element, priority);

}
isEmpty() {
return this.size() === 0;
}
clear() {

@@ -190,4 +212,5 @@ this.items = [];

exports.BaseQueue = BaseQueue;
exports.PriorityQueue = PriorityQueue;
exports.Queue = Queue;
//# sourceMappingURL=queue.js.map
'use strict';
class Stack {
constructor() {
constructor(capacity = Number.POSITIVE_INFINITY) {
this.items = [];
// 不可改变
Object.defineProperty(this, 'capacity', {
value: capacity,
writable: false
});
}

@@ -10,5 +15,10 @@ toArray() {

}
push(...p) {
this.items.push(...p);
return this.size();
push(p) {
if (this.isFull()) {
return new Error('has full');
}
else {
this.items.push(p);
return this.size();
}
}

@@ -24,2 +34,5 @@ pop() {

}
isFull() {
return this.size() === this.capacity;
}
clear() {

@@ -26,0 +39,0 @@ this.items = [];

// 考虑添加exchange功能
// 可以使用removeAt() + insert()实现
class BaseChain {
constructor() {
constructor(capacity = Number.POSITIVE_INFINITY) {
this.head = null;
this.length = 0;
Object.defineProperty(this, 'capacity', {
value: capacity,
writable: false
});
}

@@ -21,22 +25,22 @@ toArray() {

}
isEmpty() {
return !this.length;
}
isFull() {
return this.length === this.capacity;
}
}
class SingleChain extends BaseChain {
constructor(...p) {
super();
if (p.length) {
this.head = p.reduceRight((r, c, index) => {
return {
value: c,
next: r,
position: index,
};
}, null);
this.length = p.length;
}
// constructor 是实例化的过程。参数是为整个对象执行实例化时需要的内容。
// 不应该是使用时的数据。即使这个功能方便后续使用。
constructor(capacity = Number.POSITIVE_INFINITY) {
super(capacity);
this.head = null;
this.length = 0;
}
createNode(v, p) {
createNode(v, p = -1) {
return {
value: v,
next: null,
position: p,
position: p, // 负数表示不在链上
};

@@ -46,2 +50,5 @@ }

append(p) {
if (this.isFull()) {
return new Error('has full');
}
let node = this.createNode(p, this.length);

@@ -119,38 +126,2 @@ if (!this.head) {

}
// 删除此方法
// removeElement(v: T, all = false) {
// let res: B = false
// if (this.length) {
// if (this.head.value === v) {
// this.head = this.head.next
// this.length--
// res = true
// } else {
// let cur = this.head.next
// let pre = this.head
// while (cur) {
// if (cur.value === v) {
// pre.next = cur.next
// this.length--
// res = true
// if (!all) {
// break
// }
// }
// pre = cur
// cur = cur.next
// }
// }
// let cur = this.head
// let index = 0
// while (cur) {
// cur.position = index
// index++
// cur = cur.next
// }
// } else {
// res = false
// }
// return res
// }
// includes() {}

@@ -217,6 +188,6 @@ reverseSelf() {

class DoublyChain extends BaseChain {
constructor(...p) {
super();
constructor(capacity = Number.POSITIVE_INFINITY) {
super(capacity);
this.tail = null;
p.forEach(this.append, this);
// p.forEach(this.append, this)
}

@@ -232,2 +203,5 @@ createNode(v, p) {

append(v) {
if (this.isFull()) {
return new Error('has full');
}
let node = this.createNode(v, this.length);

@@ -315,33 +289,2 @@ if (this.length) {

}
// removeElement(v: T, all = false) {
// let res: B = false
// let cur = this.head
// let index = 0
// while (index < this.length) {
// if (cur.value === v) {
// if (index === 0) {
// // op this.head
// this.head = this.head.next
// this.head.prev = null
// } else if (index === this.length) {
// // op this.tail
// this.tail = this.tail.prev
// this.tail.next = null
// } else {
// // op middle
// cur.prev.next = cur.next
// cur.next.prev = cur.prev
// }
// res = true
// this.length--
// if (!all) {
// break
// }
// } else {
// index++
// }
// cur = cur.next
// }
// return res
// }
clear() {

@@ -365,8 +308,8 @@ this.head = null;

class SingleCircleChain extends SingleChain {
constructor(...p) {
super();
constructor(capacity = Number.POSITIVE_INFINITY) {
super(capacity);
this.head = null;
this.tail = null;
this.length = 0;
p.forEach(this.append, this);
// p.forEach(this.append, this)
}

@@ -392,2 +335,5 @@ toArray() {

append(v) {
if (this.isFull()) {
return new Error('has full');
}
let node = this.createNode(v, this.length);

@@ -477,5 +423,5 @@ if (this.length) {

class DoublyCircleChain extends DoublyChain {
constructor(...p) {
super();
p.forEach(this.append, this);
constructor(capacity = Number.POSITIVE_INFINITY) {
super(capacity);
// p.forEach(this.append, this)
}

@@ -491,2 +437,5 @@ createNode(v, p) {

append(p) {
if (this.isFull()) {
return new Error('has full');
}
let node = this.createNode(p, this.length);

@@ -579,32 +528,2 @@ if (this.length) {

}
// removeElement(v: T, all = false) {
// let res: B = false
// let cur = this.head
// let index = 0
// while (index < this.length) {
// if (cur.value === v) {
// if (index === 0) {
// this.head = this.head.next
// this.head.prev = this.tail
// this.tail.next = this.head
// } else if (index === this.length) {
// this.tail = this.tail.prev
// this.tail.next = this.head
// this.head.prev = this.tail
// } else {
// cur.prev.next = cur.next
// cur.next.prev = cur.prev
// }
// res = true
// this.length--
// if (!all) {
// break
// }
// } else {
// index++
// }
// cur = cur.next
// }
// return res
// }
toArray() {

@@ -634,3 +553,3 @@ let res = [];

export { DoublyChain, DoublyCircleChain, SingleChain, SingleCircleChain };
export { BaseChain, DoublyChain, DoublyCircleChain, SingleChain, SingleCircleChain };
//# sourceMappingURL=chain.js.map
// 可以抽象出BaseQueue
class BaseQueue {
constructor() {
constructor(capacity = Number.POSITIVE_INFINITY) {
this.items = [];
// this.capacity = capacity
// Object.defineProperty('')
Object.defineProperty(this, 'capacity', {
value: capacity,
writable: false
});
}

@@ -18,4 +24,6 @@ getHead() {

}
isFull() {
return this.size() === this.capacity;
}
clear() {
// return
this.items = [];

@@ -25,9 +33,21 @@ }

class Queue extends BaseQueue {
constructor(...p) {
super();
this.enqueue(...p);
// constructor(...p: T[]) {
// super()
// this.enqueue(...p)
// }
constructor(capacity = Number.POSITIVE_INFINITY) {
super(capacity);
}
enqueue(...p) {
this.items.push(...p);
return this.size();
// enqueue(...p: T[]) {
// this.items.push(...p)
// return this.size()
// }
enqueue(p) {
if (this.isFull()) {
return new Error('has full');
}
else {
this.items.push(p);
return this.size();
}
}

@@ -50,6 +70,8 @@ dequeue() {

class PriorityQueue extends BaseQueue {
constructor(defaultPriority = 0) {
super();
// this.items = []
this.defaultPriority = defaultPriority;
constructor(capacity = Number.POSITIVE_INFINITY, defaultPriority = 0) {
super(capacity);
Object.defineProperty(this, 'defaultPriority', {
value: defaultPriority,
writable: false
});
}

@@ -90,2 +112,5 @@ highestPriority() {

enqueue(element, priority = this.defaultPriority, positionFlag = true, needSetPosition = true) {
if (this.isFull()) {
return new Error('has full');
}
let len = this.size();

@@ -145,5 +170,2 @@ let node = this.createNode(element, priority);

}
isEmpty() {
return this.size() === 0;
}
clear() {

@@ -187,3 +209,3 @@ this.items = [];

export { PriorityQueue, Queue };
export { BaseQueue, PriorityQueue, Queue };
//# sourceMappingURL=queue.js.map
class Stack {
constructor() {
constructor(capacity = Number.POSITIVE_INFINITY) {
this.items = [];
// 不可改变
Object.defineProperty(this, 'capacity', {
value: capacity,
writable: false
});
}

@@ -8,5 +13,10 @@ toArray() {

}
push(...p) {
this.items.push(...p);
return this.size();
push(p) {
if (this.isFull()) {
return new Error('has full');
}
else {
this.items.push(p);
return this.size();
}
}

@@ -22,2 +32,5 @@ pop() {

}
isFull() {
return this.size() === this.capacity;
}
clear() {

@@ -24,0 +37,0 @@ this.items = [];

{
"name": "data-footstone",
"version": "0.1.17-alpha.0",
"version": "0.1.17",
"description": "data structure",

@@ -89,3 +89,3 @@ "author": "feigebaobei <18515195415@163.com>",

},
"gitHead": "0e46d12203aa0653e208098cdacf87b215bb1060"
"gitHead": "78bbeaff332c959b3eccef9563a139d434923f4d"
}
// 考虑添加exchange功能
// 可以使用removeAt() + insert()实现
class BaseChain {
constructor() {
constructor(capacity = Number.POSITIVE_INFINITY) {
this.head = null;
this.length = 0;
Object.defineProperty(this, 'capacity', {
value: capacity,
writable: false
});
}

@@ -21,22 +25,22 @@ toArray() {

}
isEmpty() {
return !this.length;
}
isFull() {
return this.length === this.capacity;
}
}
class SingleChain extends BaseChain {
constructor(...p) {
super();
if (p.length) {
this.head = p.reduceRight((r, c, index) => {
return {
value: c,
next: r,
position: index,
};
}, null);
this.length = p.length;
}
// constructor 是实例化的过程。参数是为整个对象执行实例化时需要的内容。
// 不应该是使用时的数据。即使这个功能方便后续使用。
constructor(capacity = Number.POSITIVE_INFINITY) {
super(capacity);
this.head = null;
this.length = 0;
}
createNode(v, p) {
createNode(v, p = -1) {
return {
value: v,
next: null,
position: p,
position: p, // 负数表示不在链上
};

@@ -46,2 +50,5 @@ }

append(p) {
if (this.isFull()) {
return new Error('has full');
}
let node = this.createNode(p, this.length);

@@ -119,38 +126,2 @@ if (!this.head) {

}
// 删除此方法
// removeElement(v: T, all = false) {
// let res: B = false
// if (this.length) {
// if (this.head.value === v) {
// this.head = this.head.next
// this.length--
// res = true
// } else {
// let cur = this.head.next
// let pre = this.head
// while (cur) {
// if (cur.value === v) {
// pre.next = cur.next
// this.length--
// res = true
// if (!all) {
// break
// }
// }
// pre = cur
// cur = cur.next
// }
// }
// let cur = this.head
// let index = 0
// while (cur) {
// cur.position = index
// index++
// cur = cur.next
// }
// } else {
// res = false
// }
// return res
// }
// includes() {}

@@ -217,6 +188,6 @@ reverseSelf() {

class DoublyChain extends BaseChain {
constructor(...p) {
super();
constructor(capacity = Number.POSITIVE_INFINITY) {
super(capacity);
this.tail = null;
p.forEach(this.append, this);
// p.forEach(this.append, this)
}

@@ -232,2 +203,5 @@ createNode(v, p) {

append(v) {
if (this.isFull()) {
return new Error('has full');
}
let node = this.createNode(v, this.length);

@@ -315,33 +289,2 @@ if (this.length) {

}
// removeElement(v: T, all = false) {
// let res: B = false
// let cur = this.head
// let index = 0
// while (index < this.length) {
// if (cur.value === v) {
// if (index === 0) {
// // op this.head
// this.head = this.head.next
// this.head.prev = null
// } else if (index === this.length) {
// // op this.tail
// this.tail = this.tail.prev
// this.tail.next = null
// } else {
// // op middle
// cur.prev.next = cur.next
// cur.next.prev = cur.prev
// }
// res = true
// this.length--
// if (!all) {
// break
// }
// } else {
// index++
// }
// cur = cur.next
// }
// return res
// }
clear() {

@@ -365,8 +308,8 @@ this.head = null;

class SingleCircleChain extends SingleChain {
constructor(...p) {
super();
constructor(capacity = Number.POSITIVE_INFINITY) {
super(capacity);
this.head = null;
this.tail = null;
this.length = 0;
p.forEach(this.append, this);
// p.forEach(this.append, this)
}

@@ -392,2 +335,5 @@ toArray() {

append(v) {
if (this.isFull()) {
return new Error('has full');
}
let node = this.createNode(v, this.length);

@@ -477,5 +423,5 @@ if (this.length) {

class DoublyCircleChain extends DoublyChain {
constructor(...p) {
super();
p.forEach(this.append, this);
constructor(capacity = Number.POSITIVE_INFINITY) {
super(capacity);
// p.forEach(this.append, this)
}

@@ -491,2 +437,5 @@ createNode(v, p) {

append(p) {
if (this.isFull()) {
return new Error('has full');
}
let node = this.createNode(p, this.length);

@@ -579,32 +528,2 @@ if (this.length) {

}
// removeElement(v: T, all = false) {
// let res: B = false
// let cur = this.head
// let index = 0
// while (index < this.length) {
// if (cur.value === v) {
// if (index === 0) {
// this.head = this.head.next
// this.head.prev = this.tail
// this.tail.next = this.head
// } else if (index === this.length) {
// this.tail = this.tail.prev
// this.tail.next = this.head
// this.head.prev = this.tail
// } else {
// cur.prev.next = cur.next
// cur.next.prev = cur.prev
// }
// res = true
// this.length--
// if (!all) {
// break
// }
// } else {
// index++
// }
// cur = cur.next
// }
// return res
// }
toArray() {

@@ -633,2 +552,2 @@ let res = [];

}
export { SingleChain, DoublyChain, SingleCircleChain, DoublyCircleChain };
export { BaseChain, SingleChain, DoublyChain, SingleCircleChain, DoublyCircleChain };
// 可以抽象出BaseQueue
class BaseQueue {
constructor() {
constructor(capacity = Number.POSITIVE_INFINITY) {
this.items = [];
// this.capacity = capacity
// Object.defineProperty('')
Object.defineProperty(this, 'capacity', {
value: capacity,
writable: false
});
}

@@ -18,4 +24,6 @@ getHead() {

}
isFull() {
return this.size() === this.capacity;
}
clear() {
// return
this.items = [];

@@ -25,9 +33,21 @@ }

class Queue extends BaseQueue {
constructor(...p) {
super();
this.enqueue(...p);
// constructor(...p: T[]) {
// super()
// this.enqueue(...p)
// }
constructor(capacity = Number.POSITIVE_INFINITY) {
super(capacity);
}
enqueue(...p) {
this.items.push(...p);
return this.size();
// enqueue(...p: T[]) {
// this.items.push(...p)
// return this.size()
// }
enqueue(p) {
if (this.isFull()) {
return new Error('has full');
}
else {
this.items.push(p);
return this.size();
}
}

@@ -50,6 +70,8 @@ dequeue() {

class PriorityQueue extends BaseQueue {
constructor(defaultPriority = 0) {
super();
// this.items = []
this.defaultPriority = defaultPriority;
constructor(capacity = Number.POSITIVE_INFINITY, defaultPriority = 0) {
super(capacity);
Object.defineProperty(this, 'defaultPriority', {
value: defaultPriority,
writable: false
});
}

@@ -90,2 +112,5 @@ highestPriority() {

enqueue(element, priority = this.defaultPriority, positionFlag = true, needSetPosition = true) {
if (this.isFull()) {
return new Error('has full');
}
let len = this.size();

@@ -145,5 +170,2 @@ let node = this.createNode(element, priority);

}
isEmpty() {
return this.size() === 0;
}
clear() {

@@ -187,2 +209,2 @@ this.items = [];

// 不写循环队列。它应该写在循环链表。
export { Queue, PriorityQueue };
export { BaseQueue, Queue, PriorityQueue };
class Stack {
constructor() {
constructor(capacity = Number.POSITIVE_INFINITY) {
this.items = [];
// 不可改变
Object.defineProperty(this, 'capacity', {
value: capacity,
writable: false
});
}

@@ -8,5 +13,10 @@ toArray() {

}
push(...p) {
this.items.push(...p);
return this.size();
push(p) {
if (this.isFull()) {
return new Error('has full');
}
else {
this.items.push(p);
return this.size();
}
}

@@ -22,2 +32,5 @@ pop() {

}
isFull() {
return this.size() === this.capacity;
}
clear() {

@@ -24,0 +37,0 @@ this.items = [];

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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