Skip to content

Commit f066ac8

Browse files
authored
feat: Add constructor (#25)
2 parents ea9854a + e57debf commit f066ac8

File tree

9 files changed

+5533331
-26
lines changed

9 files changed

+5533331
-26
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,15 @@ To use this package, you can import it in your JavaScript code as follows:
2929

3030
```javascript
3131
// This is a WIP example
32-
import { printMessage, processMessage } from "bmssp";
32+
import { BMSSP } from "bmssp";
3333

34-
printMessage("Hello, World!");
35-
processMessage("Hello, World!");
34+
const myBMSSP = new BMSSP([
35+
[0, 1, 50],
36+
[1, 2, 75],
37+
[0, 2, 25],
38+
]);
39+
40+
console.log(myBMSSP.graph);
3641
```
3742

3843
The file must use ECMAScript modules (ESM) syntax and have the `.mjs` file extension. Go to the `examples` directory for more usage examples.

examples/main.mjs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
import { printMessage } from "bmssp";
1+
import { BMSSP } from "bmssp";
22

3-
console.log(printMessage("Hello, World!"));
3+
const myBMSSP = new BMSSP([
4+
[0, 1, 50],
5+
[1, 2, 75],
6+
[0, 2, 25],
7+
]);
8+
9+
console.log(myBMSSP.graph);

index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { printMessage, processMessage } from "./src/bmssp.mjs";
1+
export { BMSSP } from "./src/bmssp.mjs";

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bmssp",
3-
"version": "0.11.0",
3+
"version": "0.12.0",
44
"description": "Javascript package implementation of the bmssp algorithm.",
55
"main": "index.mjs",
66
"keywords": [

src/bmssp.mjs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
function printMessage(message) {
2-
return message;
1+
class BMSSP {
2+
constructor(inputGraph) {
3+
this.graph = [];
4+
for (let edge of inputGraph) {
5+
// Create a deep copy of each edge array
6+
this.graph.push([...edge]);
7+
}
8+
}
39
}
410

5-
function processMessage(message) {
6-
return `Processed: ${message}`;
7-
}
8-
9-
export { printMessage, processMessage };
11+
export { BMSSP };

0 commit comments

Comments
 (0)