8.2.1 • Published 2 years ago
arc-lib v8.2.1
arc-lib
A convenience wrapper around my ARC utilities
Install
$ npm install arc-lib --saveWraps
Exports
{
is,
ArcArray,
ArcCheck,
ArcDate,
ArcEvents,
ArcObject,
ArcRegExp,
ArcRouter,
ArcHash,
ArcScheduler
}Random Utilities
- arc-is: Is a simple type checker that honors inheritence, checks most native types properly, and has two modes to check between strict types vs soft types. To use simply:
is(val) === 'array' - arc-check: Is a complex inclusion/exclusion check.
- arc-events: A relatively standard on/emit events model, with some additional features ie.
.once,.catchAllas well as a mixin to turn any object into an even emitter. - arc-router: Is a very thin functional router, for complex URL/Path mapping. It takes a map of urls or paths, and is able to take an evaluation string, and map it to a match while also pulling appropriate variables from the path.
- arc-hash: Provides a very simple but consistent approach to generating md5 and sha256 hashes for both scalar and non-scalar types in javascript (objects and arrays in particular).
- arc-scheduler: A scheduler and task manager for recurrent tasks. Supports both event based reaction (ie. NEW_HOUR / NEW_DAY / NEW_WEEK) as well as a fully managed task-scheduling suite (ie. Fire a job on the first Monday of every month at 8:00am)
Type Utilities
- arc-array: Is a native array wrapper with a number of convenience methods such as:
.shuffle,.rand,.pMap(asynchronous mapping) - arc-object: Is a native object wrapper with convenience methods such as
.copy(which performs a deep copy),.freeze(make it immutable), and some array like functions. - arc-reg-exp: Is a native object wrapper around RegExp that exposes some convenience methods, such as
.matchAll,.matchAndReplace,.replaceCallback - arc-date: Is a very thin Date formatting utility
Example Usage
const {is,ArcRouter,ArcEvents} = require('arc-lib');
//Pretend we're useful useful
const SomeViewController = {};
//Use ArcEvents to mixin events on the object
ArcEvents.mixin(SomeViewController);
//Bind an event
SomeViewController.on('validPath',(_path,_id)=>{
console.log(_path,_id);
});
//Setup a functional router
const SomeRouter = new ArcRouter({
'/some/**path[/]/#id':'validPath'
});
//Travel a path
const routeData = SomeRouter.travel('/some/resource/path/75');
//We should match
if(routeData.match){
//Path in the resolved path and id from the path
SomeViewController.emit(routeData.match,[routeData.path,routeData.id]);
}
//Will console.log('resource/path',75) by trigger the validPath event8.2.1
2 years ago
8.2.0
2 years ago
8.1.0
3 years ago
8.0.0
3 years ago
7.1.2
4 years ago
7.1.1
4 years ago
7.1.0
4 years ago
6.0.1
4 years ago
6.0.0
4 years ago
6.0.2
4 years ago
7.0.0
4 years ago
5.0.0
4 years ago
4.6.3
4 years ago
4.6.2
5 years ago
4.6.1
5 years ago
4.6.0
6 years ago
4.5.0
6 years ago
4.4.0
6 years ago
4.3.0
7 years ago
4.2.0
7 years ago
4.1.0
7 years ago
4.0.2
7 years ago
4.0.1
7 years ago
4.0.0
7 years ago
3.0.1
7 years ago
3.0.0
8 years ago
2.2.0
9 years ago
2.1.0
9 years ago
2.0.0
9 years ago
1.9.0
9 years ago
1.8.0
9 years ago
1.7.0
9 years ago
1.6.0
9 years ago
1.4.0
9 years ago
1.3.2
9 years ago
1.3.1
9 years ago
1.3.0
9 years ago
1.2.2
9 years ago
1.2.1
9 years ago
1.2.0
10 years ago
1.1.0
10 years ago
1.0.1
10 years ago
1.0.0
10 years ago
0.1.4
10 years ago
0.1.3
10 years ago
0.1.2
10 years ago
0.1.1
10 years ago
0.1.0
10 years ago
0.0.2
10 years ago