https://github.com/chandq/sculp-js
frontend js utils, achieve by ts, support esm、commonjs、umd
https://github.com/chandq/sculp-js
commonjs esm js-utils typescript umd
Last synced: 3 months ago
JSON representation
frontend js utils, achieve by ts, support esm、commonjs、umd
- Host: GitHub
- URL: https://github.com/chandq/sculp-js
- Owner: chandq
- License: mit
- Created: 2023-10-15T11:32:02.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-08-06T07:53:53.000Z (11 months ago)
- Last Synced: 2025-08-06T09:34:08.895Z (11 months ago)
- Topics: commonjs, esm, js-utils, typescript, umd
- Language: TypeScript
- Homepage: https://chandq.github.io/sculp-js/
- Size: 1.26 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# sculp-js
**A Modern JavaScript Utility Library for Web**
[](https://github.com/chandq/sculp-js/actions/workflows/node.js.yml)
[](https://www.npmjs.com/package/sculp-js)
[](https://github.com/chandq/sculp-js/blob/main/LICENSE.md)
[](https://codecov.io/gh/chandq/sculp-js)
> A lightweight utility library written in TypeScript with zero dependencies, supporting ESM, CJS, and UMD formats.
**[API Documentation](https://chandq.github.io/sculp-js/)** • **[Getting Started](#usage)** • **[Features](#features)**
## ✨ Features
- **Type-Safe**: Full TypeScript support with comprehensive type definitions
- **Zero Dependencies**: Pure native implementation, no external libraries
- **Tree Shaking**: Supports selective imports for smaller bundle sizes
- **Multi-Format**: ESM, CJS, and UMD builds available
- **Web Focused**: Optimized for modern web environments
### Core Utilities
Type Checking
- `isString`, `isNumber`, `isBoolean`, `isFunction`, `isObject`, `isArray`
- `isDate`, `isRegExp`, `isUndefined`, `isNull`, `isError`, `isNaN`
- `isPrimitive`, `isSymbol`, `isBigInt`, `isPlainObject`
- `isEmpty`, `isNodeList`, `isValidDate`, `typeIs`
Data Structures
- **Array**: `arrayEach`, `arrayEachAsync`, `arrayInsertBefore`, `arrayRemove`
- **Tree**: `forEachDeep`, `mapDeep`, `findDeep`, `filterDeep`, `searchTreeById`, `flatTree`, `fuzzySearchTree`
- **Object**: `objectAssign`, `objectGet`, `objectHas`, `cloneDeep`, `objectPick`, `objectOmit`
Web APIs
- **DOM**: `addClass`, `hasClass`, `removeClass`, `getStyle`, `setStyle`
- **File**: `chooseLocalFile`, `compressImg`
- **Clipboard**: `copyText`, `fallbackCopyText`
- **Download**: `downloadBlob`, `downloadURL`, `downloadData`
- **Watermark**: `genCanvasWM`
Encoding & Validation
- **Encode/Decode**: `weBtoa`, `weAtob`, `b64encode`, `b64decode`
- **Validation**: `isEmail`, `isPhone`, `isUrl`, `isIDNO`, `isIPv4`, `isIPv6`
Additional Utils
- **Date**: `formatDate`, `calculateDate`, `dateToStart`, `dateToEnd`
- **String**: `stringCamelCase`, `stringKebabCase`, `parseQueryParams`, `stringEscapeHTML`
- **Math**: `add`, `subtract`, `multiply`, `divide`, `numberAbbr`
- **Functional**: `debounce`, `throttle`, `once`, `wait`
## 🚀 Installation
### npm
```bash
npm install sculp-js
```
### CDN
```html
```
## 💡 Usage
```js
import { forEachDeep, cloneDeep } from 'sculp-js';
// Deep traversal of tree structures
const tree = [
{
id: 1,
name: 'Parent 1',
children: [
{ id: 11, name: 'Child 1' },
{ id: 12, name: 'Child 2', children: [{ id: 121, name: 'Grandchild 1' }] }
]
},
{ id: 2, name: 'Parent 2' }
];
const names = [];
forEachDeep(tree, item => {
names.push(item.name);
});
// names = ['Parent 1', 'Child 1', 'Child 2', 'Grandchild 1', 'Parent 2']
// Deep cloning of objects
const original = { a: 1, b: { c: 2 } };
const cloned = cloneDeep(original);
```
## 📦 Module Formats
```js
// ES Modules (recommended)
import { cloneDeep } from 'sculp-js';
// Individual module imports
import cloneDeep from 'sculp-js/cloneDeep';
// CommonJS
const { cloneDeep } = require('sculp-js');
```
## 📄 License
MIT License © 2023-present, [chandq](https://github.com/chandq)