-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
99 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { fCode, tCode } from "../../src/chars"; | ||
import { unsafeCharCodeAt } from "../../src/util"; | ||
|
||
/** | ||
* Deserialize a string to type array | ||
* @param data data to parse | ||
* @returns boolean | ||
*/ | ||
// @ts-ignore: Decorator | ||
@inline export function deserializeArray<T extends any[]>(data: string, start: i32 = 0, end = data.length): T { | ||
if (start - end < 3) return instantiate<T>(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { eCode, fCode, tCode } from "../../src/chars"; | ||
import { unsafeCharCodeAt } from "../../src/util"; | ||
import { deserializeBoolean } from "../boolean"; | ||
|
||
// @ts-ignore: Decorator | ||
@inline export function deserializeooleanArray<T extends bool[]>(data: string): T { | ||
const result = instantiate<T>(); | ||
let lastPos = 1; | ||
for (let i = 1; i < data.length - 1; i++) { | ||
const char = unsafeCharCodeAt(data, i); | ||
if (char === tCode || char === fCode) { | ||
lastPos = i; | ||
} else if (char === eCode) { | ||
i++; | ||
result.push(deserializeBoolean(data, lastPos, i)); | ||
} | ||
} | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { backSlashCode, quoteCode } from "../../src/chars"; | ||
import { unsafeCharCodeAt } from "../../src/util"; | ||
import { deserializeString } from "../string"; | ||
|
||
// @ts-ignore: Decorator | ||
@inline export function deserializeStringArray(data: string): string[] { | ||
const result: string[] = []; | ||
let lastPos = 0; | ||
let instr = false; | ||
let escaping = false;v | ||
for (let i = 1; i < data.length - 1; i++) { | ||
const char = unsafeCharCodeAt(data, i); | ||
if (char === backSlashCode && !escaping) { | ||
escaping = true; | ||
} else { | ||
if (char === quoteCode && !escaping) { | ||
if (instr === false) { | ||
instr = true; | ||
lastPos = i; | ||
} else { | ||
instr = false; | ||
result.push(deserializeString(data, lastPos, i)); | ||
} | ||
} | ||
escaping = false; | ||
} | ||
} | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters