Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
rename 'CIRCULAR' tson key to 'Reference'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheraff committed Oct 8, 2023
1 parent 30d85f2 commit f62151b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ test("back-reference: circular object reference", () => {
"{
\\"json\\": {
\\"a\\": [
\\"CIRCULAR\\",
\\"Reference\\",
\\"\\",
\\"__tson\\"
],
\\"b\\": [
\\"CIRCULAR\\",
\\"Reference\\",
\\"\\",
\\"__tson\\"
]
Expand Down Expand Up @@ -100,12 +100,12 @@ test("back-reference: circular array reference", () => {
"{
\\"json\\": [
[
\\"CIRCULAR\\",
\\"Reference\\",
\\"\\",
\\"__tson\\"
],
[
\\"CIRCULAR\\",
\\"Reference\\",
\\"\\",
\\"__tson\\"
]
Expand Down Expand Up @@ -140,7 +140,7 @@ test("back-reference: referential equality", () => {
\\"json\\": {
\\"a\\": {},
\\"b\\": [
\\"CIRCULAR\\",
\\"Reference\\",
\\"a\\",
\\"__tson\\"
],
Expand All @@ -150,7 +150,7 @@ test("back-reference: referential equality", () => {
\\"__tson\\"
],
\\"d\\": [
\\"CIRCULAR\\",
\\"Reference\\",
\\"c\\",
\\"__tson\\"
]
Expand Down Expand Up @@ -188,7 +188,7 @@ test("back-reference: grandparent reference", () => {
\\"a\\": {
\\"b\\": {
\\"a\\": [
\\"CIRCULAR\\",
\\"Reference\\",
\\"a__tson__a\\",
\\"__tson__\\"
]
Expand Down Expand Up @@ -222,7 +222,7 @@ test("back-reference: self-referencing Map", () => {
[
\\"a\\",
[
\\"CIRCULAR\\",
\\"Reference\\",
\\"\\",
\\"__tson__\\"
]
Expand Down Expand Up @@ -261,7 +261,7 @@ test("back-reference: self-referencing Map deep", () => {
\\"a\\",
{
\\"foo\\": [
\\"CIRCULAR\\",
\\"Reference\\",
\\"\\",
\\"__tson__\\"
]
Expand Down Expand Up @@ -296,7 +296,7 @@ test("back-reference: self-referencing Set", () => {
\\"Set\\",
[
[
\\"CIRCULAR\\",
\\"Reference\\",
\\"\\",
\\"__tson__\\"
]
Expand Down Expand Up @@ -330,7 +330,7 @@ test("back-reference: self-referencing Set deep", () => {
[
{
\\"foo\\": [
\\"CIRCULAR\\",
\\"Reference\\",
\\"\\",
\\"__tson__\\"
]
Expand Down
2 changes: 1 addition & 1 deletion src/sync/deserialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function createTsonDeserialize(opts: TsonOptions): TsonDeserializeFn {
const key = path.join(nonce);
if (isTsonTuple(value, nonce)) {
const [type, serializedValue] = value;
if (type === "CIRCULAR") {
if (type === "Reference") {
references.push([key, serializedValue as string]);
return nonce;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sync/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function createTsonSerialize(opts: TsonOptions): TsonSerializeFn {
if (isComplex) {
const prev = seen.get(value);
if (prev) {
return ["CIRCULAR", prev.join(nonce), nonce] as TsonTuple;
return ["Reference", prev.join(nonce), nonce] as TsonTuple;
}

seen.set(value, path);
Expand Down

0 comments on commit f62151b

Please sign in to comment.