How to use just-pick - 9 common examples

To help you get started, we’ve selected a few just-pick examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fanfoujs / space-fanfou / src / features / index.js View on Github external
const optionDef = {
    key: optionName,
    isSoldered,
    isSubOption,
    disableCloudSyncing,
    type: do {
      if (isSoldered || typeof defaultValue === 'boolean') {
        'checkbox' // eslint-disable-line no-unused-expressions
      } else if (typeof defaultValue === 'number') {
        'number' // eslint-disable-line no-unused-expressions
      } else {
        // eslint-disable-next-line unicorn/prefer-type-error
        throw new Error('无法判断选项的类型,因为没有指定 `isSoldered` 或 `defaultValue`')
      }
    },
    ...pick(rawOptionDef, [ 'label', 'comment', 'controlOptions' ]),
  }

  if (isSubOption) {
    optionDef.parentKey = featureName
  }

  return optionDef
}
github uber / baseweb / documentation-site / components / yard / config / notification.ts View on Github external
value: undefined,
      type: PropTypes.Boolean,
      description:
        'When set to true a close button is displayed and the notification can be dismissed by a user.',
    },
    children: {
      value: '{() => "This is a notification."}',
      type: PropTypes.Function,
      description: `Toast notification content. The children-as-function
        receives a dismiss method that can be called to
        dismiss the notification and can be used as a
        handler for an action inside the toast content.
        React.ChildrenArray type is also accepted.`,
      placeholder: '({dismiss}) => {}',
    },
    ...pick(changeHandlers, ['onBlur', 'onFocus']),
    onClose: {
      value: undefined,
      type: PropTypes.Function,
      description: `A callback function called when a notification is dismissed.`,
      placeholder: '() => {}',
    },
    autoHideDuration: {
      value: undefined,
      type: PropTypes.Number,
      description: `The number of milliseconds to wait before automatically dismissing a
        notification. This behavior is disabled when the value is set to 0.`,
      placeholder: '10000',
    },
    ...pick(changeHandlers, ['onMouseEnter', 'onMouseLeave']),
    overrides: {
      value: undefined,
github uber / baseweb / documentation-site / components / yard / config / input.ts View on Github external
description: 'Name attribute.',
    hidden: true,
  },
  min: {
    value: undefined,
    type: PropTypes.String,
    description: 'min value when used as input type=number',
    hidden: true,
  },
  max: {
    value: undefined,
    type: PropTypes.String,
    description: 'max value when used as input type=number',
    hidden: true,
  },
  ...pick(changeHandlers, [
    'onBlur',
    'onKeyDown',
    'onKeyPress',
    'onKeyUp',
    'onFocus',
  ]),
  required: {
    value: false,
    type: PropTypes.Boolean,
    description: 'Renders component in required state.',
    hidden: true,
  },
};

const InputConfig: TConfig = {
  imports: {
github fanfoujs / space-fanfou / src / background / feature / createSubfeatureClass.js View on Github external
constructor({ featureName, subfeatureName, script, parent }) {
    this.featureName = featureName
    this.subfeatureName = subfeatureName
    this.parent = parent
    this.initContext()

    const featureScriptObj = script(this.context)

    this.migrations = featureScriptObj.migrations
    this.script = pick(featureScriptObj, [
      'onLoad',
      'onSettingsChange',
      'onUnload',
    ])
  }
github fanfoujs / space-fanfou / src / content / feature / createSubfeatureClass.js View on Github external
if (style) {
      this.style = {
        element: null,
        code: style,
      }
    }

    if (script) {
      const featureScriptObj = script(this.context) || {}

      if (featureScriptObj.waitReady) {
        this.waitReadyFns.push(featureScriptObj.waitReady)
      }

      this.migrations = featureScriptObj.migrations
      this.script = pick(featureScriptObj, [
        'applyWhen',
        'onLoad',
        'onSettingsChange',
        'onUnload',
      ])
    }

    this.isApplicable = simpleMemoize(
      this.script?.applyWhen ||
      (() => Promise.resolve(true)),
    )
  }
github uber / baseweb / documentation-site / components / yard / config / radio.ts View on Github external
description: 'Set to be focused (active) on selectedchecked radio.',
      hidden: true,
    },
    'aria-label': {
      value: undefined,
      type: PropTypes.String,
      description: `Sets aria-label attribute.`,
      hidden: true,
    },
    'aria-labelledby': {
      value: undefined,
      type: PropTypes.String,
      description: `Sets aria-labelledby attribute.`,
      hidden: true,
    },
    ...pick(changeHandlers, [
      'onBlur',
      'onFocus',
      'onMouseLeave',
      'onMouseEnter',
    ]),
    overrides: {
      value: undefined,
      type: PropTypes.Custom,
      description: 'Lets you customize all aspects of the component.',
      custom: {
        names: [
          'Root',
          'Input',
          'Label',
          'RadioGroupRoot',
          'RadioMarkInner',
github fanfoujs / space-fanfou / src / background / feature / createFeatureClass.js View on Github external
async loadOptionValues() {
    const optionValues = await settings.readAll()

    this.optionValuesCache = pick(optionValues, this.metadata.optionNames)
  }
github uber / baseweb / documentation-site / components / yard / config / select.ts View on Github external
description:
        'Change handler of the select to be called when a value is changed.',
      propHook: {
        what: 'JSON.stringify(params.value)',
        into: 'value',
      },
      placeholder: '({value, option, type}) => value',
    },
    filterOptions: {
      value: undefined,
      type: PropTypes.Function,
      description:
        'A custom method to filter options to be displayed in the dropdown.',
      placeholder: '(options) => options',
    },
    ...pick(changeHandlers, ['onBlur', 'onFocus']),
    onInputChange: {
      value: undefined,
      type: PropTypes.Function,
      description: 'Change handler of the search input.',
      placeholder: '(event) => {}',
    },
    onOpen: {
      value: undefined,
      type: PropTypes.Function,
      description: 'A function that is called when the dropdown opens.',
      placeholder: '() => {}',
    },
    onClose: {
      value: undefined,
      type: PropTypes.Function,
      description: 'A function that is called when the dropdown closes.',
github fanfoujs / space-fanfou / src / background / feature / createSubfeatureClass.js View on Github external
initContext() {
    this.waitReadyFns = []

    this.context = pick(this, [
      'requireModules',
      'readOptionValue',
    ])
  }

just-pick

copy an object but with only the specified keys

MIT
Latest version published 2 years ago

Package Health Score

61 / 100
Full package analysis

Popular just-pick functions