Page MenuHomeSealhub

remove.ts
No OneTemporary

remove.ts

import { predicates, ShapeToType } from "@sealcode/ts-predicates";
import type Context from "../../../../context.js";
import { ArrayAction } from "./array-action.js";
const RemoveInputShape = {
remove: predicates.or(predicates.string, predicates.number),
};
const RemoveParsedShape = { remove: predicates.number };
export class Remove extends ArrayAction<
ShapeToType<typeof RemoveInputShape>,
ShapeToType<typeof RemoveParsedShape>
> {
InputShape = RemoveInputShape;
async _parse(
_context: Context,
input: ShapeToType<typeof RemoveInputShape>
): Promise<ShapeToType<typeof RemoveParsedShape> | null> {
return { remove: parseInt(input.remove.toString()) };
}
async run<T>(
_context: Context,
action: ShapeToType<typeof RemoveParsedShape>,
array: T[]
) {
array = array.filter((_, i) => {
return i !== action.remove;
});
return array;
}
}

File Metadata

Mime Type
text/x-java
Expires
Wed, May 7, 19:51 (15 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
636233
Default Alt Text
remove.ts (869 B)

Event Timeline