Skip to content

Commit 71c9c99

Browse files
committed
Add githook & Update readme
1 parent 103d017 commit 71c9c99

File tree

6 files changed

+845
-15
lines changed

6 files changed

+845
-15
lines changed

.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
coverage/
3+
dist/
4+
build/
5+
package-lock.json
6+
package.json

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"printWidth": 80,
3+
"singleQuote": true,
4+
"trailingComma": "es5"
5+
}

README.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ For more information, please check [wiki](https://en.wikipedia.org/wiki/Priority
1010

1111
During practising some challenges in `leetcode`. I found this [problem](https://leetcode.com/problems/last-stone-weight/) requires `priority queue`. So I decided to research some documentations online and try to implement by myself this lib. The result beats 97% in `leetcode`.
1212

13+
## Installation
14+
15+
_npm_
16+
17+
```bash
18+
npm i p-queue-ts
19+
```
20+
21+
_yarn_
22+
23+
```bash
24+
yarn add p-queue-ts
25+
```
26+
1327
## Usage
1428

1529
The `priority queue` lib uses max heap as a default way to build a queue.
@@ -37,12 +51,12 @@ const p = new PriorityQueue(function (a, b) {
3751
return a.value < b.value;
3852
});
3953

40-
p.push({ text: "a", value: 2 });
41-
p.push({ text: "b", value: 7 });
42-
p.push({ text: "c", value: 4 });
43-
p.push({ text: "d", value: 1 });
44-
p.push({ text: "e", value: 8 });
45-
p.push({ text: "f", value: 1 });
54+
p.push({ text: 'a', value: 2 });
55+
p.push({ text: 'b', value: 7 });
56+
p.push({ text: 'c', value: 4 });
57+
p.push({ text: 'd', value: 1 });
58+
p.push({ text: 'e', value: 8 });
59+
p.push({ text: 'f', value: 1 });
4660

4761
/** The queue
4862
[
@@ -83,12 +97,12 @@ const p = new PriorityQueue(function (a, b) {
8397
return a.value > b.value;
8498
});
8599

86-
p.push({ text: "a", value: 2 });
87-
p.push({ text: "b", value: 7 });
88-
p.push({ text: "c", value: 4 });
89-
p.push({ text: "d", value: 1 });
90-
p.push({ text: "e", value: 8 });
91-
p.push({ text: "f", value: 1 });
100+
p.push({ text: 'a', value: 2 });
101+
p.push({ text: 'b', value: 7 });
102+
p.push({ text: 'c', value: 4 });
103+
p.push({ text: 'd', value: 1 });
104+
p.push({ text: 'e', value: 8 });
105+
p.push({ text: 'f', value: 1 });
92106

93107
/** The queue
94108
[

0 commit comments

Comments
 (0)