2.0.1 • Published 6 months ago

@blockbite/shared-utils v2.0.1

Weekly downloads
-
License
GPL-2.0-or-later
Repository
-
Last release
6 months ago

Shared Utilities

A collection of shared Blockbite JavaScript/TypeScript utilities.

Installation

pnpm add @blockbite/shared-utils
# or
npm install @blockbite/shared-utils

Usage Examples

Array Utilities

import { getClosest, chunkArray } from '@blockbite/shared-utils';

const closest = getClosest([10, 20, 30], 25); // 20
const chunks = chunkArray([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]

Webpack Helpers

const { blockbiteDefaultConfig } = require('@blockbite/shared-utils');

// Use with wp-scripts
const defaultConfig = blockbiteDefaultConfig(wpConfig);
const originalEntry = defaultConfig.entry;

defaultConfig.entry = async () => {
  const defaultEntries = await originalEntry();
  const customEntries = {
    'blockbite-bb': path.resolve(process.cwd(), 'src/core', 'bb.ts'),
    'blockbite-core': path.resolve(process.cwd(), 'src/core', 'core.ts'),
  };
  const finalEntries = { ...defaultEntries, ...customEntries };

  return finalEntries;
};

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

2.0.1

6 months ago

2.0.0

6 months ago