@traversable/schema
    Preparing search index...
    writeable: (schema: Fixpoint, options?: deepEqual.Options) => string

    Type declaration

      • (schema: Fixpoint, options?: deepEqual.Options): string
      • Derive a "writeable" (stringified) "deep equal" function from a Json Schema spec.

        A "deep equal" function (see also, Equal) is similar to lodash's isEqual function, except more performant, because when the shape of the values being compared is known ahead of time, we can optimize ahead of time, and only check what's necessary.

        Note that the deep equal function generated by JsonSchema.deepEqual assumes that both values have already been validated. Passing unvalidated values to the function might result in undefined behavior.

        JsonSchema.deepEqual.writeable accepts an optional configuration object as its second argument; documentation for those options are available via hover on autocompletion.

        See also:

        Parameters

        Returns string

        import { JsonSchema } from '@traversable/json-schema'

        const deepEqual = JsonSchema.deepEqual.writeable({
        type: 'object',
        required: ['street1', 'city'],
        properties: {
        street1: { type: 'string' },
        street2: { type: 'string' },
        city: { type: 'string' },
        }
        }, { typeName: 'Address' })

        console.log(deepEqual)
        // =>
        // type Address = { street1: string; street2?: string; city: string; }
        // function deepEqual(x: Address, y: Address) {
        // if (x === y) return true;
        // if (x.street1 !== y.street1) return false;
        // if (x.street2 !== y.street2) return false;
        // if (x.city !== y.city) return false;
        // return true;
        // }