@nait-aits/helper

1.4.1 • Public • Published

Installation

// with npm
npm install @nait-aits/helper

Usage Examples

1. React Hooks Helpers

import {
  usePrevious,
  useMultiStates,
  useMapStates,
  useDebounce,
  useEditDebounce,
  useOneState,
  useUndoableState,
} from "@nait-aits/helper/hooks";

const SamplePage = (props: Props) => {
  const [count, setCount] = useState(0);
  const prev = usePrevious(count);

  return <></>;
};

export default SamplePage;

2. A set of polyfill methods available to call globaly.

  • Array.avg
  • Array.compact
  • Array.chunk
  • Array.groupBy
  • Array.isEqualTo
  • Array.max
  • Array.maxOf
  • Array.min
  • Array.minOf
  • Array.orderBy
  • Array.sample
  • Array.sum
  • Array.uniq
  • Array.uniqOf
  • Array.without
  • Function.compose
  • Function.curry
  • Function.partial
  • Function.partialArg
  • Number.pad
  • Object.isEqual
  • String.isWhiteSpace
  • globalThis.isNullish
  • globalThis.reactClassNames

Please see details in each method and type definition. Simply import the file at the top in the root file like app.tsx or index.tsx, and the methods will be available globally.

import "@nait-aits/helper/polyfills";

If your project includes Storybook, please add the require statement to .storybook/preview.js file.

require("@nait-aits/helper/polyfills");

For newer version of webpack, you may need to use polyfills-es instead.

import "@nait-aits/helper/polyfills-es";

3. Cryptography hash and encryption functions

import {
  SHA1Hash,
  SHA256Hash,
  SHA512Hash,
  AESEncrypt,
  AESDecrypt,
} from "@nait-aits/helper/cryptography";

/@nait-aits/helper/

    Package Sidebar

    Install

    npm i @nait-aits/helper

    Weekly Downloads

    162

    Version

    1.4.1

    License

    MIT

    Unpacked Size

    106 kB

    Total Files

    36

    Last publish

    Collaborators

    • kenlinait
    • edelyn