Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
fs-context committed Dec 15, 2024
1 parent 571dc76 commit 06dbee7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/fs-context/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export type ExtractField<A extends (string | ArgumentDefine)[]> = {
export interface BlockConfigA<T extends (string | ArgumentDefine)[]> {
method?: MethodFunction<ExtractField<T>>;
type?: BlockTypePlain;
opcode?: string;
opcode: string;
}
export interface BlockConfigB<T extends ArgumentDefine[]> {
arguments?: T;
Expand Down
26 changes: 14 additions & 12 deletions src/fs-context/structs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ export class Block<O extends Extension = Extension> {
method: (this: O, args: any) => any = () => { };
arguments: ArgumentPart[] = [];
type: BlockTypePlain = "command";
private _opcode: string | null = null;
private _opcode: string = "";
get opcode(): string {
return this._opcode ? this._opcode : md5(JSON.stringify(this.arguments));
return this._opcode;
}
get text(): string {
let result: string = "";
Expand Down Expand Up @@ -104,7 +104,7 @@ export class Block<O extends Extension = Extension> {
return new Block<O>({
method: realMethod,
type: realConfig.type,
opcode: method?.name
opcode: method?.name || Unnecessary.internalUUID.next()
}, ...textLoaded);
}
constructor(config?: BlockConfigA<[]>, ...args: any[]) {
Expand All @@ -123,15 +123,17 @@ export class Block<O extends Extension = Extension> {
}
this.arguments.push(currentPart);
};
const data = config || {};
if (data.method) {
this.method = data.method;
};
if (data.type) {
this.type = data.type;
};
if (data.opcode) {
this._opcode = data.opcode;
if (config) {
const data = config;
if (data.method) {
this.method = data.method;
};
if (data.type) {
this.type = data.type;
};
if (data.opcode) {
this._opcode = data.opcode;
};
};
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/fs-context/tools.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import md5 from "md5";
import {
AcceptedInputType,
ArgumentPart,
Expand Down Expand Up @@ -107,14 +106,15 @@ export namespace Unnecessary {
const result = [];
for (let i = 0; i < this.length; i++) {
this.last++;
result.push(md5(this.last + i.toString()).slice(0, 5));
result.push(this.last.toString(32).slice(0, 5));
}
return result.join('-');
}
constructor(length: number = 4) {
this.length = length;
}
}
export const internalUUID = new UUIDAutoscalator();
export function splitArgBoxPart(str: string, substrings: string[]) {
const filteredSubstrings = [];
for (let i = 0; i < str.length; i++) {
Expand Down

0 comments on commit 06dbee7

Please sign in to comment.