Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

arc-lib

Package Overview
Dependencies
Maintainers
0
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arc-lib

ARC

  • 8.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

arc-lib

A convenience wrapper around my ARC utilities

Install

$ npm install arc-lib --save

Wraps

  • arc-is
  • arc-array
  • arc-check
  • arc-date
  • arc-events
  • arc-object
  • arc-reg-exp
  • arc-router
  • arc-hash
  • arc-scheduler

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, .catchAll as 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 event

FAQs

Package last updated on 12 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc