@dabble/patches 0.7.13 → 0.7.14

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.
@@ -202,9 +202,11 @@ function createOrderGetter(orderField) {
202
202
  function sortByOrder(items, orderField = "order") {
203
203
  const getOrder = createOrderGetter(orderField);
204
204
  return Object.entries(items).sort((a, b) => {
205
- const orderCmp = getOrder(a[1]).localeCompare(getOrder(b[1]));
205
+ const orderA = getOrder(a[1]);
206
+ const orderB = getOrder(b[1]);
207
+ const orderCmp = orderA < orderB ? -1 : orderA > orderB ? 1 : 0;
206
208
  if (orderCmp !== 0) return orderCmp;
207
- return a[0].localeCompare(b[0]);
209
+ return a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
208
210
  });
209
211
  }
210
212
  function healDuplicateOrders(items, orderField = "order") {
@@ -1,4 +1,5 @@
1
1
  import "../chunk-IZ2YBCUP.js";
2
+ import { escapePathComponent } from "./utils/escapePathComponent.js";
2
3
  const proxyFodder = {};
3
4
  const createPathProxy = pathProxy;
4
5
  function pathProxy(path = "") {
@@ -9,7 +10,7 @@ function pathProxy(path = "") {
9
10
  return path;
10
11
  };
11
12
  }
12
- return pathProxy(`${path}/${prop}`);
13
+ return pathProxy(`${path}/${escapePathComponent(prop)}`);
13
14
  },
14
15
  set(_, prop) {
15
16
  throw new Error(
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Escapes a single path component for use in a JSON Pointer (RFC 6901).
3
+ * `~` is escaped as `~0` and `/` is escaped as `~1`.
4
+ */
5
+ declare function escapePathComponent(component: string): string;
6
+
7
+ export { escapePathComponent };
@@ -0,0 +1,7 @@
1
+ import "../../chunk-IZ2YBCUP.js";
2
+ function escapePathComponent(component) {
3
+ return component.replace(/~/g, "~0").replace(/\//g, "~1");
4
+ }
5
+ export {
6
+ escapePathComponent
7
+ };
@@ -1,4 +1,5 @@
1
1
  export { deepEqual } from './deepEqual.js';
2
+ export { escapePathComponent } from './escapePathComponent.js';
2
3
  export { get } from './get.js';
3
4
  export { getOpData } from './getOpData.js';
4
5
  export { getType, getTypeLike } from './getType.js';
@@ -1,4 +1,5 @@
1
1
  export * from "./deepEqual.js";
2
+ export * from "./escapePathComponent.js";
2
3
  export * from "./get.js";
3
4
  export * from "./getOpData.js";
4
5
  export * from "./getType.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dabble/patches",
3
- "version": "0.7.13",
3
+ "version": "0.7.14",
4
4
  "description": "Immutable JSON Patch implementation based on RFC 6902 supporting operational transformation and last-writer-wins",
5
5
  "author": "Jacob Wright <jacwright@gmail.com>",
6
6
  "bugs": {