@swan-io/lake 7.0.6 → 7.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-io/lake",
3
- "version": "7.0.6",
3
+ "version": "7.0.8",
4
4
  "engines": {
5
5
  "node": ">=18.0.0",
6
6
  "yarn": "^1.22.0"
@@ -1,2 +1,3 @@
1
1
  export declare const isPlainObject: (value: unknown) => boolean;
2
- export declare const pick: <T extends Record<K, unknown>, const K extends keyof T>(object: T, keys: K[]) => Pick<T, K>;
2
+ export declare const pick: <T extends Record<PropertyKey, unknown>, const K extends keyof T>(object: T, keys: K[]) => Pick<T, K>;
3
+ export declare const omit: <T extends Record<PropertyKey, unknown>, const K extends keyof T>(object: T, keys: K[]) => Omit<T, K>;
@@ -5,3 +5,7 @@ export const pick = (object, keys) => {
5
5
  const allowedKeys = new Set(keys);
6
6
  return Object.fromEntries(Object.entries(object).filter(([key]) => allowedKeys.has(key)));
7
7
  };
8
+ export const omit = (object, keys) => {
9
+ const disallowedKeys = new Set(keys);
10
+ return Object.fromEntries(Object.entries(object).filter(([key]) => !disallowedKeys.has(key)));
11
+ };
@@ -1,7 +1,10 @@
1
+ import { Option } from "@swan-io/boxed";
1
2
  export declare const safeSplitAround: (string: string, expression: string) => string[];
2
3
  export declare const deburr: (value: string) => string;
4
+ export declare const trim: (value: string) => string;
3
5
  export declare const words: (value: string) => string[];
4
6
  export declare const lowerCase: <T extends string>(value: T) => Lowercase<T>;
5
7
  export declare const upperCase: <T extends string>(value: T) => Uppercase<T>;
6
8
  export declare const capitalize: <T extends string>(value: T) => Capitalize<T>;
7
9
  export declare const uncapitalize: <T extends string>(value: T) => Uncapitalize<T>;
10
+ export declare const optionFromString: (value: string) => Option<string>;
@@ -1,3 +1,4 @@
1
+ import { Option } from "@swan-io/boxed";
1
2
  export const safeSplitAround = (string, expression) => {
2
3
  let index = 0;
3
4
  const splitString = [];
@@ -225,8 +226,10 @@ export const deburr = (value) => {
225
226
  .replace(reLatin, char => { var _a; return (_a = deburredLetters[char]) !== null && _a !== void 0 ? _a : ""; })
226
227
  .replace(/[\u0300-\u036f]/g, "");
227
228
  };
229
+ export const trim = (value) => value.trim();
228
230
  export const words = (value) => value.split(/\b/).filter(x => /^[a-zA-Z0-9]+$/.test(x));
229
231
  export const lowerCase = (value) => value.toLowerCase();
230
232
  export const upperCase = (value) => value.toUpperCase();
231
233
  export const capitalize = (value) => `${value.charAt(0).toUpperCase()}${value.slice(1)}`;
232
234
  export const uncapitalize = (value) => `${value.charAt(0).toLowerCase()}${value.slice(1)}`;
235
+ export const optionFromString = (value) => value !== "" ? Option.Some(value) : Option.None();