datalist-interface
Advanced tools
+35
-11
@@ -1,2 +0,7 @@ | ||
| export class DatalistInterface { | ||
| /** | ||
| * A basic interface for a list. | ||
| * | ||
| * @template Item | ||
| */ | ||
| export class DatalistInterface<Item> { | ||
| /** | ||
@@ -6,39 +11,58 @@ * Create a new data list. | ||
| * | ||
| * @constructor | ||
| * @param {Iterable} values | ||
| * @param {Item[]} values | ||
| */ | ||
| constructor(values: Iterable<any>) | ||
| constructor(values: Item[]) | ||
| values: any[] | ||
| /** | ||
| * Add all arguments. | ||
| * | ||
| * @param {Item[]} values | ||
| * @return {this} | ||
| */ | ||
| add(...args: any[]): DatalistInterface | ||
| add(...values: Item[]): this | ||
| /** | ||
| * Remove all arguments. | ||
| * | ||
| * @param {Item[]} values | ||
| * @return {this} | ||
| */ | ||
| remove(...args: any[]): DatalistInterface | ||
| remove(...values: Item[]): this | ||
| /** | ||
| * Check whether `value` is in this list. | ||
| * | ||
| * @param {Item} value | ||
| * @return {boolean} | ||
| */ | ||
| is(value: any): boolean | ||
| is(value: Item): boolean | ||
| /** | ||
| * Check whether `value` is in this list. | ||
| * | ||
| * @param {Item} value | ||
| * @return {boolean} | ||
| */ | ||
| has(value: any): boolean | ||
| has(value: Item): boolean | ||
| /** | ||
| * Get all values. | ||
| * | ||
| * @return {Item[]} | ||
| */ | ||
| all(): any[] | ||
| all(): Item[] | ||
| /** | ||
| * Get all values. | ||
| * | ||
| * @return {Item[]} | ||
| */ | ||
| valueOf(): any[] | ||
| valueOf(): Item[] | ||
| /** | ||
| * Get all values. | ||
| * | ||
| * @return {Item[]} | ||
| */ | ||
| toJSON(): any[] | ||
| toJSON(): Item[] | ||
| /** | ||
| * Serialize all values. | ||
| * | ||
| * @return {string} | ||
| */ | ||
| toString(): string | ||
| } |
+31
-7
@@ -0,1 +1,6 @@ | ||
| /** | ||
| * A basic interface for a list. | ||
| * | ||
| * @template Item | ||
| */ | ||
| export class DatalistInterface { | ||
@@ -6,4 +11,3 @@ /** | ||
| * | ||
| * @constructor | ||
| * @param {Iterable} values | ||
| * @param {Item[]} values | ||
| */ | ||
@@ -17,5 +21,8 @@ constructor(values) { | ||
| * Add all arguments. | ||
| * | ||
| * @param {Item[]} values | ||
| * @return {this} | ||
| */ | ||
| add(/* values... */) { | ||
| this.values.push(...arguments) | ||
| add(...values) { | ||
| this.values.push(...values) | ||
| return this | ||
@@ -26,9 +33,12 @@ } | ||
| * Remove all arguments. | ||
| * | ||
| * @param {Item[]} values | ||
| * @return {this} | ||
| */ | ||
| remove(/* values... */) { | ||
| var index = arguments.length | ||
| remove(...values) { | ||
| var index = values.length | ||
| var position | ||
| while (index--) { | ||
| position = this.values.indexOf(arguments[index]) | ||
| position = this.values.indexOf(values[index]) | ||
@@ -45,2 +55,5 @@ if (position !== -1) { | ||
| * Check whether `value` is in this list. | ||
| * | ||
| * @param {Item} value | ||
| * @return {boolean} | ||
| */ | ||
@@ -53,2 +66,5 @@ is(value) { | ||
| * Check whether `value` is in this list. | ||
| * | ||
| * @param {Item} value | ||
| * @return {boolean} | ||
| */ | ||
@@ -61,2 +77,4 @@ has(value) { | ||
| * Get all values. | ||
| * | ||
| * @return {Item[]} | ||
| */ | ||
@@ -69,2 +87,4 @@ all() { | ||
| * Get all values. | ||
| * | ||
| * @return {Item[]} | ||
| */ | ||
@@ -77,2 +97,4 @@ valueOf() { | ||
| * Get all values. | ||
| * | ||
| * @return {Item[]} | ||
| */ | ||
@@ -85,2 +107,4 @@ toJSON() { | ||
| * Serialize all values. | ||
| * | ||
| * @return {string} | ||
| */ | ||
@@ -87,0 +111,0 @@ toString() { |
+1
-1
| { | ||
| "name": "datalist-interface", | ||
| "version": "2.0.0", | ||
| "version": "2.1.0", | ||
| "description": "Simple interface for a list functioning as a database", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
8688
8.59%161
42.48%