Socket
Socket
Sign inDemoInstall

data-structure-typed

Package Overview
Dependencies
Maintainers
1
Versions
201
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data-structure-typed - npm Package Compare versions

Comparing version 1.19.1 to 1.19.2

11

dist/data-structures/heap/heap.d.ts

@@ -11,2 +11,9 @@ /**

export declare class HeapItem<T = number> {
/**
* The constructor function initializes an instance of a class with a priority and a value.
* @param {number} priority - The `priority` parameter is a number that represents the priority of the value. It is
* optional and has a default value of `NaN`.
* @param {T | null} [val=null] - The `val` parameter is of type `T | null`, which means it can accept a value of type
* `T` or `null`.
*/
constructor(priority?: number, val?: T | null);

@@ -29,4 +36,4 @@ private _priority;

get pq(): PriorityQueue<HeapItem<T>>;
protected _priorityCb: (val: T) => number;
get priorityCb(): (val: T) => number;
protected _priorityExtractor: (val: T) => number;
get priorityExtractor(): (val: T) => number;
/**

@@ -33,0 +40,0 @@ * The function returns the size of a priority queue.

23

dist/data-structures/heap/heap.js

@@ -5,2 +5,9 @@ "use strict";

var HeapItem = /** @class */ (function () {
/**
* The constructor function initializes an instance of a class with a priority and a value.
* @param {number} priority - The `priority` parameter is a number that represents the priority of the value. It is
* optional and has a default value of `NaN`.
* @param {T | null} [val=null] - The `val` parameter is of type `T | null`, which means it can accept a value of type
* `T` or `null`.
*/
function HeapItem(priority, val) {

@@ -43,10 +50,10 @@ if (priority === void 0) { priority = NaN; }

if (options) {
var priority = options.priority;
if (priority !== undefined && typeof priority !== 'function') {
var priorityExtractor = options.priorityExtractor;
if (priorityExtractor !== undefined && typeof priorityExtractor !== 'function') {
throw new Error('.constructor expects a valid priority function');
}
this._priorityCb = priority || (function (el) { return +el; });
this._priorityExtractor = priorityExtractor || (function (el) { return +el; });
}
else {
this._priorityCb = function (el) { return +el; };
this._priorityExtractor = function (el) { return +el; };
}

@@ -61,5 +68,5 @@ }

});
Object.defineProperty(Heap.prototype, "priorityCb", {
Object.defineProperty(Heap.prototype, "priorityExtractor", {
get: function () {
return this._priorityCb;
return this._priorityExtractor;
},

@@ -123,7 +130,7 @@ enumerable: false,

}
if (Number.isNaN(+priority) && Number.isNaN(this._priorityCb(val))) {
if (Number.isNaN(+priority) && Number.isNaN(this._priorityExtractor(val))) {
throw new Error('.add expects a numeric priority '
+ 'or a constructor callback that returns a number');
}
var _priority = !Number.isNaN(+priority) ? priority : this._priorityCb(val);
var _priority = !Number.isNaN(+priority) ? priority : this._priorityExtractor(val);
this._pq.add(new HeapItem(_priority, val));

@@ -130,0 +137,0 @@ return this;

export * from './abstract-binary-tree';
export * from './abstract-graph';
export * from './avl-tree';
export * from './binary-tree';
export * from './bst';
export * from './avl-tree';
export * from './directed-graph';
export * from './doubly-linked-list';
export * from './heap';
export * from './navigator';
export * from './priority-queue';
export * from './rb-tree';
export * from './segment-tree';
export * from './singly-linked-list';
export * from './tree-multiset';
export * from './abstract-graph';
export * from './directed-graph';
export * from './undirected-graph';
export * from './priority-queue';
export * from './heap';
export * from './singly-linked-list';
export * from './doubly-linked-list';
export * from './navigator';

@@ -18,13 +18,15 @@ "use strict";

__exportStar(require("./abstract-binary-tree"), exports);
__exportStar(require("./abstract-graph"), exports);
__exportStar(require("./avl-tree"), exports);
__exportStar(require("./binary-tree"), exports);
__exportStar(require("./bst"), exports);
__exportStar(require("./avl-tree"), exports);
__exportStar(require("./directed-graph"), exports);
__exportStar(require("./doubly-linked-list"), exports);
__exportStar(require("./heap"), exports);
__exportStar(require("./navigator"), exports);
__exportStar(require("./priority-queue"), exports);
__exportStar(require("./rb-tree"), exports);
__exportStar(require("./segment-tree"), exports);
__exportStar(require("./singly-linked-list"), exports);
__exportStar(require("./tree-multiset"), exports);
__exportStar(require("./abstract-graph"), exports);
__exportStar(require("./directed-graph"), exports);
__exportStar(require("./undirected-graph"), exports);
__exportStar(require("./priority-queue"), exports);
__exportStar(require("./heap"), exports);
__exportStar(require("./singly-linked-list"), exports);
__exportStar(require("./doubly-linked-list"), exports);
__exportStar(require("./navigator"), exports);
export type HeapOptions<T> = {
priority?: (element: T) => number;
priorityExtractor?: (element: T) => number;
};
export * from './data-structures';
export * from './utils';

@@ -18,1 +18,2 @@ "use strict";

__exportStar(require("./data-structures"), exports);
__exportStar(require("./utils"), exports);
{
"name": "data-structure-typed",
"version": "1.19.1",
"version": "1.19.2",
"description": "Javascript & TypeScript Data Structure Library, meticulously crafted to empower developers with a versatile set of essential data structures. Our library includes a wide range of data structures, such as Binary Tree, AVL Tree, Binary Search Tree (BST), Tree Multiset, Segment Tree, Binary Indexed Tree, Graph, Directed Graph, Undirected Graph, Singly Linked List, Hash, CoordinateSet, CoordinateMap, Heap, Doubly Linked List, Priority Queue, Max Priority Queue, Min Priority Queue, Queue, ObjectDeque, ArrayDeque, Stack, and Trie. Each data structure is thoughtfully designed and implemented using TypeScript to provide efficient, reliable, and easy-to-use solutions for your programming needs. Whether you're optimizing algorithms, managing data, or enhancing performance, our TypeScript Data Structure Library is your go-to resource. Elevate your coding experience with these fundamental building blocks for software development.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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