@papillonbits/library 1.10.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +219 -1
- package/package.json +2 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1 +1,219 @@
|
|
|
1
|
-
|
|
1
|
+
# @papillonbits/library
|
|
2
|
+
|
|
3
|
+
Modular JavaScript utility library with helper functions for common programming tasks.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@papillonbits/library)
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
A comprehensive collection of utility functions organized by category, providing reusable solutions for array manipulation, date formatting, state management, and more.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @papillonbits/library
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Modules
|
|
18
|
+
|
|
19
|
+
### a11y - Accessibility Utilities
|
|
20
|
+
Helper functions for improving web accessibility, ARIA attributes, and assistive technology support.
|
|
21
|
+
|
|
22
|
+
### array - Array Manipulation
|
|
23
|
+
Functions for working with arrays including filtering, mapping, reducing, and transforming data structures.
|
|
24
|
+
|
|
25
|
+
### auth - Authentication Utilities
|
|
26
|
+
Helper functions for authentication, authorization, token management, and user session handling.
|
|
27
|
+
|
|
28
|
+
### boolean - Boolean Helpers
|
|
29
|
+
Utilities for boolean logic, type coercion, and conditional operations.
|
|
30
|
+
|
|
31
|
+
### browser - Browser Detection & Utilities
|
|
32
|
+
Functions for browser detection, feature detection, user agent parsing, and browser-specific utilities.
|
|
33
|
+
|
|
34
|
+
### date - Date Formatting & Manipulation
|
|
35
|
+
Date utilities for formatting, parsing, comparing, and manipulating dates and timestamps.
|
|
36
|
+
|
|
37
|
+
### event - Event Handling Utilities
|
|
38
|
+
Helper functions for DOM event handling, event delegation, and custom event management.
|
|
39
|
+
|
|
40
|
+
### hooks - Custom React Hooks
|
|
41
|
+
Reusable React hooks for common patterns like state management, side effects, and component lifecycle.
|
|
42
|
+
|
|
43
|
+
### number - Number Formatting & Utilities
|
|
44
|
+
Functions for number formatting, parsing, validation, and mathematical operations.
|
|
45
|
+
|
|
46
|
+
### object - Object Manipulation
|
|
47
|
+
Utilities for object creation, transformation, deep cloning, merging, and property access.
|
|
48
|
+
|
|
49
|
+
### pagination - Pagination Logic
|
|
50
|
+
Functions for calculating page numbers, page ranges, and pagination state management.
|
|
51
|
+
|
|
52
|
+
### sort - Sorting Utilities
|
|
53
|
+
Sorting algorithms and comparator functions for various data types and structures.
|
|
54
|
+
|
|
55
|
+
### store - State Management Utilities
|
|
56
|
+
Helper functions for Redux store management, action creators, and state selectors.
|
|
57
|
+
|
|
58
|
+
### string - String Manipulation
|
|
59
|
+
String utilities for formatting, parsing, validation, and transformation.
|
|
60
|
+
|
|
61
|
+
## Usage
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
// Import specific modules
|
|
65
|
+
import { formatDate } from '@papillonbits/library/date';
|
|
66
|
+
import { sortByProperty } from '@papillonbits/library/sort';
|
|
67
|
+
import { debounce } from '@papillonbits/library/event';
|
|
68
|
+
|
|
69
|
+
// Use the utilities
|
|
70
|
+
const formattedDate = formatDate(new Date(), 'YYYY-MM-DD');
|
|
71
|
+
const sortedArray = sortByProperty(items, 'name');
|
|
72
|
+
const debouncedHandler = debounce(handleInput, 300);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
// Import from main entry point
|
|
77
|
+
import { date, sort, event } from '@papillonbits/library';
|
|
78
|
+
|
|
79
|
+
const formattedDate = date.formatDate(new Date());
|
|
80
|
+
const sortedItems = sort.sortByProperty(items, 'name');
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Features
|
|
84
|
+
|
|
85
|
+
- **Modular Design** - Import only what you need for optimal bundle size
|
|
86
|
+
- **Pure Functions** - Side-effect free, testable utilities
|
|
87
|
+
- **Well Typed** - PropTypes and JSDoc for type safety
|
|
88
|
+
- **Tree Shakeable** - Optimized for tree shaking
|
|
89
|
+
- **Well Tested** - Comprehensive test coverage
|
|
90
|
+
- **Zero Dependencies** - Lightweight with no external dependencies
|
|
91
|
+
|
|
92
|
+
## Development
|
|
93
|
+
|
|
94
|
+
### Building
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# Build the package
|
|
98
|
+
npm run build
|
|
99
|
+
|
|
100
|
+
# Build for different environments
|
|
101
|
+
npm run build-test
|
|
102
|
+
npm run build-acceptance
|
|
103
|
+
npm run build-release
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Scripts
|
|
107
|
+
|
|
108
|
+
- `clean-up` - Remove build artifacts and dependencies
|
|
109
|
+
- `install-packages` - Install dependencies
|
|
110
|
+
- `build` - Transpile and build the package (ignores tests)
|
|
111
|
+
|
|
112
|
+
## Build Process
|
|
113
|
+
|
|
114
|
+
The build process:
|
|
115
|
+
1. Removes existing `build/` directory
|
|
116
|
+
2. Transpiles source with Babel
|
|
117
|
+
3. Copies files preserving structure
|
|
118
|
+
4. Ignores test files (`**/__tests__`)
|
|
119
|
+
|
|
120
|
+
## File Structure
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
packages/library/
|
|
124
|
+
├── src/
|
|
125
|
+
│ ├── a11y/
|
|
126
|
+
│ ├── array/
|
|
127
|
+
│ ├── auth/
|
|
128
|
+
│ ├── boolean/
|
|
129
|
+
│ ├── browser/
|
|
130
|
+
│ ├── date/
|
|
131
|
+
│ ├── event/
|
|
132
|
+
│ ├── hooks/
|
|
133
|
+
│ ├── number/
|
|
134
|
+
│ ├── object/
|
|
135
|
+
│ ├── pagination/
|
|
136
|
+
│ ├── sort/
|
|
137
|
+
│ ├── store/
|
|
138
|
+
│ └── string/
|
|
139
|
+
└── build/ (generated)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Each module directory contains:
|
|
143
|
+
- `index.js` - Module exports
|
|
144
|
+
- `*.js` - Implementation files
|
|
145
|
+
- `__tests__/` - Test files (not included in build)
|
|
146
|
+
|
|
147
|
+
## Testing
|
|
148
|
+
|
|
149
|
+
All utilities are tested with Jest:
|
|
150
|
+
```bash
|
|
151
|
+
# Run tests from root
|
|
152
|
+
npm run test
|
|
153
|
+
|
|
154
|
+
# Run tests in watch mode
|
|
155
|
+
npm run test:tdd
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Use Cases
|
|
159
|
+
|
|
160
|
+
### Date Formatting
|
|
161
|
+
```javascript
|
|
162
|
+
import { formatDate, parseDate } from '@papillonbits/library/date';
|
|
163
|
+
|
|
164
|
+
const formatted = formatDate(new Date(), 'MM/DD/YYYY');
|
|
165
|
+
const parsed = parseDate('2024-01-15', 'YYYY-MM-DD');
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Array Manipulation
|
|
169
|
+
```javascript
|
|
170
|
+
import { groupBy, unique } from '@papillonbits/library/array';
|
|
171
|
+
|
|
172
|
+
const grouped = groupBy(users, 'role');
|
|
173
|
+
const uniqueIds = unique(items.map(item => item.id));
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Event Handling
|
|
177
|
+
```javascript
|
|
178
|
+
import { debounce, throttle } from '@papillonbits/library/event';
|
|
179
|
+
|
|
180
|
+
const handleSearch = debounce((query) => {
|
|
181
|
+
// Search logic
|
|
182
|
+
}, 300);
|
|
183
|
+
|
|
184
|
+
const handleScroll = throttle(() => {
|
|
185
|
+
// Scroll logic
|
|
186
|
+
}, 100);
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### React Hooks
|
|
190
|
+
```javascript
|
|
191
|
+
import { useLocalStorage, useDebounce } from '@papillonbits/library/hooks';
|
|
192
|
+
|
|
193
|
+
function MyComponent() {
|
|
194
|
+
const [value, setValue] = useLocalStorage('key', 'default');
|
|
195
|
+
const debouncedValue = useDebounce(value, 500);
|
|
196
|
+
|
|
197
|
+
return <div>{debouncedValue}</div>;
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## API Documentation
|
|
202
|
+
|
|
203
|
+
For detailed API documentation of each utility function, see the source files and tests in the repository.
|
|
204
|
+
|
|
205
|
+
## Links
|
|
206
|
+
|
|
207
|
+
- [Homepage](https://github.com/papillonbits/papillonbits/tree/master/packages/library)
|
|
208
|
+
- [Repository](https://github.com/papillonbits/papillonbits)
|
|
209
|
+
- [Issues](https://github.com/papillonbits/papillonbits/issues)
|
|
210
|
+
|
|
211
|
+
## Related Packages
|
|
212
|
+
|
|
213
|
+
- [@papillonbits/components](../components) - React components
|
|
214
|
+
- [@papillonbits/css](../css) - CSS styles
|
|
215
|
+
- [@papillonbits/setup](../setup) - Build configuration
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
See root LICENSE file for details.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@papillonbits/library",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "Papillon Bits Library",
|
|
5
5
|
"homepage": "https://github.com/papillonbits/papillonbits/tree/master/packages/library",
|
|
6
6
|
"repository": {
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"build-acceptance": "npm run build",
|
|
37
37
|
"build-release": "npm run build"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "dac9692229827ceb3066693345a48e88baf159b6"
|
|
40
40
|
}
|