1.0.2 • Published 6 years ago

@vcnkit/util v1.0.2

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

VCNKit/Util

@vcnkit/util is a collection of common utility functions useful for dealing with incoming props

Installation

NPM

$ npm install --save @vcnkit/util

Yarn

$ yarn add @vcnkit/util

Usage

noop

Simple void function to use as a default prop when a function is expected.

import { noop } from '@vcnkit/util';

SomeComponent.defaultProps = {
    onChange: noop,
};

omit

Omits the specified props from the given props

import { omit } from '@vcnkit/util';

const SomeComponent = (props) => (
    <div { ...omit(props, [ 'someProp', 'anotherProp']) }>
        'someProp' and 'anotherProp' have been omitted.
    </div>
);

extract

Extracts the specified props from the given props

import { extract } from '@vcnkit/util';

const SomeComponent = (props) => (
    <div { ...extract(props, [ 'role', 'id' ]) }>
        'role' and 'id' will have been attached to this div.
    </div>
);

extractHtmlProps

Extracts valid HTML props from the given props

import { extractHtmlProps } from '@vcnkit/util';

const SomeComponent = (props) => (
    <div { ...extractHtmlProps(props) }>
        Will only attach valid HTML props
    </div>
);
1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago