UNPKG

@augmentcode/ag-redux-toolkit

Version:

Redux + Saga state management for Svelte apps — designed for AI agents. Includes runtime TypeScript source, AI skills, and reference documentation for robust, observable, high-performance state management.

31 lines (30 loc) • 1.05 kB
//#region src/utils/runtime/utils.ts /** * Asserts that a value is not null or undefined, throwing an error if it is. * This is a type guard that narrows the type to exclude null and undefined. * * @param value - The value to check * @returns The value with null and undefined excluded from its type * @throws Error if the value is null or undefined */ var assertValue = (value) => { if (value === void 0 || value === null) throw new Error("Unexpected empty value"); return value; }; /** * Removes a key from an object immutably without using `delete`. * Using destructuring instead of `delete` avoids V8 de-optimization * that can occur when objects have properties deleted. * * @param obj - The object to remove the key from * @param key - The key to remove * @returns A new object without the specified key, or the original object if key doesn't exist */ function omitKey(obj, key) { if (!(key in obj)) return obj; const { [key]: _, ...rest } = obj; return rest; } //#endregion export { assertValue, omitKey }; //# sourceMappingURL=utils.js.map