MCPcopy Create free account
hub / github.com/formkit/formkit / only

Function only

packages/utils/src/index.ts:565–582  ·  view source on GitHub ↗
(
  obj: Record<string, any>,
  include: Array<string | RegExp>
)

Source from the content-addressed store, hash-verified

563 * @public
564 */
565export function only(
566 obj: Record<string, any>,
567 include: Array<string | RegExp>
568): Record<string, any> {
569 const clean: Record<string, any> = {}
570 const exps = include.filter((n) => n instanceof RegExp) as RegExp[]
571 include.forEach((key) => {
572 if (!(key instanceof RegExp)) {
573 clean[key] = obj[key]
574 }
575 })
576 Object.keys(obj).forEach((key) => {
577 if (exps.some((exp) => exp.test(key))) {
578 clean[key] = obj[key]
579 }
580 })
581 return clean
582}
583
584/**
585 * This converts kebab-case to camelCase. It ONLY converts from kebab to camel.

Callers 4

useInputFunction · 0.90
utils.spec.tsFile · 0.90
createInitialPropsFunction · 0.90
useInputFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected