@bitblit/ratchet-common 4.0.108-alpha → 4.0.110-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  export declare class EsmRatchet {
2
- static fetchDirName(): string;
3
- static fetchFileName(): string;
2
+ static fetchDirName(root: string): string;
3
+ static fetchFileName(root: string): string;
4
4
  }
@@ -1,11 +1,17 @@
1
1
  import url from 'url';
2
2
  export class EsmRatchet {
3
- static fetchDirName() {
4
- const rval = url.fileURLToPath(new URL('.', import.meta.url));
3
+ static fetchDirName(root) {
4
+ if (!root) {
5
+ throw new Error('Need to provide root (should be import.meta.url)');
6
+ }
7
+ const rval = url.fileURLToPath(new URL('.', root));
5
8
  return rval;
6
9
  }
7
- static fetchFileName() {
8
- const rval = url.fileURLToPath(import.meta.url);
10
+ static fetchFileName(root) {
11
+ if (!root) {
12
+ throw new Error('Need to provide root (should be import.meta.url)');
13
+ }
14
+ const rval = url.fileURLToPath(root);
9
15
  return rval;
10
16
  }
11
17
  }
@@ -27,7 +27,7 @@ describe('#geolocationRatchet', function () {
27
27
  });
28
28
  it('should calc point in bounds', function () {
29
29
  const input = fs
30
- .readFileSync(path.join(EsmRatchet.fetchDirName(), '../../../../test-data/sample_geo_locations.csv'))
30
+ .readFileSync(path.join(EsmRatchet.fetchDirName(import.meta.url), '../../../../test-data/sample_geo_locations.csv'))
31
31
  .toString();
32
32
  const locations = input
33
33
  .split('\n')
@@ -83,7 +83,7 @@ describe('#fitToWindow', function () {
83
83
  });
84
84
  describe('#groupNumbersIntoContiguousRanges', function () {
85
85
  it('should group numbers', function () {
86
- let input = JSON.parse(fs.readFileSync(path.join(EsmRatchet.fetchDirName(), '../../../../test-data/number_set.json')).toString());
86
+ let input = JSON.parse(fs.readFileSync(path.join(EsmRatchet.fetchDirName(import.meta.url), '../../../../test-data/number_set.json')).toString());
87
87
  input = input.map((i) => NumberRatchet.safeNumber(i));
88
88
  const grouped = NumberRatchet.groupNumbersIntoContiguousRanges(input, 5);
89
89
  expect(grouped).toBeTruthy();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitblit/ratchet-common",
3
- "version": "4.0.108-alpha",
3
+ "version": "4.0.110-alpha",
4
4
  "description": "Common tools for general use",
5
5
  "type": "module",
6
6
  "module": "index.js",