object-shape-tester - v5.3.0
    Preparing search index...

    Function checkWrapValidShape

    • Check if a variable matches the given shape. Returns the variable if it matches, otherwise returns undefined

      Type Parameters

      Parameters

      Returns undefined | Shape["runtimeType"]

      true or false

      import {defineShape, checkWrapValidShape} from 'object-shape-tester';

      const myShape = defineShape({
      a: '',
      });

      checkWrapValidShape({a: 'hi'}, myShape); // returns `{a: 'hi'}`
      checkWrapValidShape({a: 3}, myShape); // returns `undefined`
      checkWrapValidShape({a: 'hi', b: 'bye'}, {allowExtraKeys: true}, myShape); // returns `{a: 'hi', b: 'bye'}`