Never Patronize Mothers

    @replygirl/curse
    TypeScript icon, indicating that this package has built-in type declarations

    3.0.0-beta.0 • Public • Published

    curse

    Recursively transform, search, or whatever else you wanna do to objects, arrays, and primitive values

    Installation

    yarn add @replygirl/curse

    Usage

    import curse from '@replygirl/curse'
    
    const isString = x => typeof x === 'string'
    
    const strings = curse(foo, {
      arr: x => x.filter(isString),
      obj: x => Object.values(x).flat().filter(isString)
    })

    Handlers

    All keys and values can be transformed with handlers of type (x: T, kp?: string) => any. kp is the keypath from the root object

    • arr will be called on every array, after cursing its values
    • obj will be called on every non-null object, after cursing its property values
    • key will be called on every key of every non-null object
    • val will be called on every array, null, or non-object

    Chaining

    Any returned object can be cursed again with .curse({ arr?, obj?, key?, val? })

    License

    ISC (c) 2021 replygirl

    Install

    npm i @replygirl/curse

    DownloadsWeekly Downloads

    49

    Version

    3.0.0-beta.0

    License

    ISC

    Unpacked Size

    12.8 kB

    Total Files

    17

    Last publish

    Collaborators

    • imogen