@liveblocks/client
Advanced tools
Comparing version 0.7.0 to 0.7.1
@@ -130,6 +130,33 @@ "use strict"; | ||
const items = sortedListItems(getListItems(this._cache, id)); | ||
const [itemPosition, item] = items[index]; | ||
const afterPosition = items[targetIndex][0]; | ||
const beforePosition = targetIndex === 0 ? undefined : items[targetIndex - 1][0]; | ||
if (targetIndex < 0) { | ||
throw new Error("targetIndex cannont be less than 0"); | ||
} | ||
if (targetIndex >= items.length) { | ||
throw new Error("targetIndex cannot be greater or equal than the list length"); | ||
} | ||
if (index < 0) { | ||
throw new Error("index cannont be less than 0"); | ||
} | ||
if (index >= items.length) { | ||
throw new Error("index cannot be greater or equal than the list length"); | ||
} | ||
if (index === targetIndex) { | ||
return this; | ||
} | ||
let beforePosition = null; | ||
let afterPosition = null; | ||
if (index < targetIndex) { | ||
afterPosition = | ||
targetIndex === items.length - 1 | ||
? undefined | ||
: items[targetIndex + 1][0]; | ||
beforePosition = items[targetIndex][0]; | ||
} | ||
else { | ||
afterPosition = items[targetIndex][0]; | ||
beforePosition = | ||
targetIndex === 0 ? undefined : items[targetIndex - 1][0]; | ||
} | ||
const position = position_1.makePosition(beforePosition, afterPosition); | ||
const [, item] = items[index]; | ||
return this.dispatch({ | ||
@@ -367,6 +394,6 @@ type: live_1.OpType.ListMove, | ||
function isRecord(value) { | ||
return typeof value === "object" && value.$$type === RECORD; | ||
return value != null && typeof value === "object" && value.$$type === RECORD; | ||
} | ||
function isList(value) { | ||
return typeof value === "object" && value.$$type === LIST; | ||
return value != null && typeof value === "object" && value.$$type === LIST; | ||
} | ||
@@ -373,0 +400,0 @@ function isCrdt(value) { |
@@ -125,6 +125,33 @@ import { OpType, CrdtType, } from "./live"; | ||
const items = sortedListItems(getListItems(this._cache, id)); | ||
const [itemPosition, item] = items[index]; | ||
const afterPosition = items[targetIndex][0]; | ||
const beforePosition = targetIndex === 0 ? undefined : items[targetIndex - 1][0]; | ||
if (targetIndex < 0) { | ||
throw new Error("targetIndex cannont be less than 0"); | ||
} | ||
if (targetIndex >= items.length) { | ||
throw new Error("targetIndex cannot be greater or equal than the list length"); | ||
} | ||
if (index < 0) { | ||
throw new Error("index cannont be less than 0"); | ||
} | ||
if (index >= items.length) { | ||
throw new Error("index cannot be greater or equal than the list length"); | ||
} | ||
if (index === targetIndex) { | ||
return this; | ||
} | ||
let beforePosition = null; | ||
let afterPosition = null; | ||
if (index < targetIndex) { | ||
afterPosition = | ||
targetIndex === items.length - 1 | ||
? undefined | ||
: items[targetIndex + 1][0]; | ||
beforePosition = items[targetIndex][0]; | ||
} | ||
else { | ||
afterPosition = items[targetIndex][0]; | ||
beforePosition = | ||
targetIndex === 0 ? undefined : items[targetIndex - 1][0]; | ||
} | ||
const position = makePosition(beforePosition, afterPosition); | ||
const [, item] = items[index]; | ||
return this.dispatch({ | ||
@@ -361,6 +388,6 @@ type: OpType.ListMove, | ||
function isRecord(value) { | ||
return typeof value === "object" && value.$$type === RECORD; | ||
return value != null && typeof value === "object" && value.$$type === RECORD; | ||
} | ||
function isList(value) { | ||
return typeof value === "object" && value.$$type === LIST; | ||
return value != null && typeof value === "object" && value.$$type === LIST; | ||
} | ||
@@ -367,0 +394,0 @@ function isCrdt(value) { |
{ | ||
"name": "@liveblocks/client", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./lib/cjs/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
127286
3619