@weborigami/async-tree 0.2.7 → 0.2.8

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weborigami/async-tree",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "Asynchronous tree drivers based on standard JavaScript classes",
5
5
  "type": "module",
6
6
  "main": "./main.js",
@@ -11,7 +11,7 @@
11
11
  "typescript": "5.7.2"
12
12
  },
13
13
  "dependencies": {
14
- "@weborigami/types": "0.2.7"
14
+ "@weborigami/types": "0.2.8"
15
15
  },
16
16
  "scripts": {
17
17
  "test": "node --test --test-reporter=spec",
package/src/extension.js CHANGED
@@ -89,7 +89,10 @@ export function match(key, ext) {
89
89
 
90
90
  // Key matches if it ends with the same extension
91
91
  const normalized = trailingSlash.remove(key);
92
- if (normalized.endsWith(ext)) {
92
+
93
+ if (ext === "") {
94
+ return normalized.includes(".") ? null : normalized;
95
+ } else if (normalized.endsWith(ext)) {
93
96
  const removed =
94
97
  ext.length > 0 ? normalized.slice(0, -ext.length) : normalized;
95
98
  return trailingSlash.toggle(removed, trailingSlash.has(key));
@@ -2,15 +2,14 @@ import * as extension from "../extension.js";
2
2
  import * as trailingSlash from "../trailingSlash.js";
3
3
 
4
4
  /**
5
- * Given a source resultExtension and a result resultExtension, return a pair of key
5
+ * Given a source extension and a result extension, return a pair of key
6
6
  * functions that map between them.
7
7
  *
8
8
  * The resulting `inverseKey` and `key` functions are compatible with those
9
9
  * expected by map and other transforms.
10
10
  *
11
11
  * @typedef {import("@weborigami/types").AsyncTree} AsyncTree
12
- * @param {{ resultExtension?: string, sourceExtension: string }}
13
- * options
12
+ * @param {{ resultExtension?: string, sourceExtension: string }} options
14
13
  */
15
14
  export default function keyFunctionsForExtensions({
16
15
  resultExtension,
@@ -42,7 +41,7 @@ export default function keyFunctionsForExtensions({
42
41
  function checkDeprecatedExtensionWithoutDot(extension) {
43
42
  if (extension && extension !== "/" && !extension.startsWith(".")) {
44
43
  throw new RangeError(
45
- `map: Warning: the extension "${extension}" should start with a period.`
44
+ `The extension "${extension}" must start with a period.`
46
45
  );
47
46
  }
48
47
  }
@@ -7,6 +7,7 @@ export function getRealmObjectPrototype(object: any): any;
7
7
  export const hiddenFileNames: string[];
8
8
  export function isPacked(obj: any): obj is Packed;
9
9
  export function isPlainObject(obj: any): obj is PlainObject;
10
+ export function isPrimitive(obj: any): boolean;
10
11
  export function isStringLike(obj: any): obj is StringLike;
11
12
  export function isUnpackable(obj): obj is { unpack: () => any };
12
13
  export function keysFromPath(path: string): string[];
@@ -19,6 +19,7 @@ describe("extension", () => {
19
19
  assert.equal(match("file.md", ".txt"), null);
20
20
  assert.equal(match("file.md/", ".md"), "file/");
21
21
  assert.equal(match("file", ""), "file");
22
+ assert.equal(match("file.md", ""), null);
22
23
  assert.equal(match("file", "/"), null);
23
24
  assert.equal(match("file/", "/"), "file");
24
25
  });