2.0.1 • Published 6 months ago
@blockbite/shared-utils v2.0.1
Shared Utilities
A collection of shared Blockbite JavaScript/TypeScript utilities.
Installation
pnpm add @blockbite/shared-utils
# or
npm install @blockbite/shared-utilsUsage 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.