
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
the-arbiter
Advanced tools
The Arbiter is a HTML routing and analytics system for front-end applications and websites.
The Arbiter is a HTML routing and analytics system for front-end applications and websites. (based on ExpressJS Route handling and React-like loading - for front-end only)
The Arbiter preloads pages into memory and swaps pages into a container. This significantly decreases render time and page navigation.
Custom page-specific rendering can be done in one of three states: preRender, onRender, postRender.
npm install the-arbiter
Set up
If you are using gulp in conjuction with this module, place the following code in your global.js file.
function locationHashChanged( e ) {
if( !_a.isPageRouted( location.hash ) ) return;
if( !_a.hashToKey( location.hash ) || _a.currentPage === '' ) return;
if( _a.isPageRendered( location.hash ) ) return;
_a.load( location.hash, true, () => console.log( location.hash + ' loaded' ) );
Arbiter.onLocationHashChanged( e );
}
function pageDidChange( e ) {
locationHashChanged( e );
Arbiter.onPageDidChange( e );
}
window.onhashchange = locationHashChanged;
window.addEventListener( 'popstate', pageDidChange );
document.addEventListener( 'DOMContentLoaded', e => Arbiter.onApplicationDidAppear() );
window.onload = Arbiter.onApplicationDidLoad;
window.onbeforeunload = Arbiter.onApplicationDidUnload;
Configuration
const
_pages = {
pagePath: 'main',
mainFile: 'home',
pages: [
{
name: 'home',
title: 'Website | Home',
preload: false,
data: null,
preRender: "console.log( 'pre' )",
onRender: "console.log( 'on' )",
postRender: "console.log( 'post' )"
}
]
},
Arbiter = require( 'the-arbiter' ),
_a = new Arbiter( _pages, true );
_a.init();
_pages is the primary variable. This can be an in-memory object, or loaded json.
Required keys for _pages
pagePath: (string) location of all your page filesmainFile: (string) your "index.html" or "primary" landing page.pages: (array) list of all pages in applicationRequired fields for a Page
name: (string) the name of the filetitle: (string) equivalent to <title> at the top of your pages - will set the page titlepreload: (bool) tells the application to preload your file on ApplicationDidAppearOptional fields for a Page
data (string) the raw HTML for your pagepreRender (function | string) the function called before the page is loadedonRender (function | string) the function called when the page is loadedpostRender (function | string) the function called after the page is loadedonApplicationDidAppear: called immediately when the application starts to loadonApplicationDidLoad: called after the DOM loadsonApplicationIsReady: called after The Arbiter finishes loading and the application is readyonPageDidChange: called on page change (Example: back, forward, refresh)onLocationHashChanged: called when the hyperlink hash changes (Example: #home to #login)onApplicationDidUnload: called when the application starts to closeonApplicationDidDisappear: called just before the application closesapplicationDidReceiveMemoryWarning: called if The Monitor detects a memory issue
Manages page routing, monitoring, and lifecycle.
constructor
(array) pages: config object including the array of pages for the arbiter to manage(boolean) verbose: log the Arbiter's actionscurrentPageinit
(function) fn: function to run on initialization(function) globalExecution: add globally executed functionbody container - modify this to call another div if you have a permanent navigation bar or something like thatmainFile and calls onApplicationIsReadyrender
(Page) pagepreRender, onRender, and postRender in their respective ordercurrentPagedocument.title and location.hash based on page objectrequest
(string) urlload
(string) name: name of the page(bool) render: set render page flag(function) handler: optional call backrequest's it, stores it, and then calls renderXMLHttpRequest on readyState 4changePage
(string) hashArbiter.onLocationHashChangedhashToKey
(string) hash# in location.hash URI component and returns resulthashToKey
(string) hash# for location.hash URI component and returns resultisPageRouted
(string) hashisPageLoaded
(string) hashisPageRendered
(string) hashisPage
(Page) pagepage is an instance of PagepageToHash
(Page | string) pagehash of a page or stringgetPage
(Page | string) pagePage from a hash, key, or PagesetPreRenderForPage
(Page | string) page(function) fnPreRender function for a specific pagesetOnRenderForPage
(Page | string) page(function) fnOnRender function for a specific pagesetPostRenderForPage
(Page | string) page(function) fnPostRender function for a specific pagesetMainFile
(string) pagemainFile on in-memory configuationlogin to dashboardaddGlobalExecution
(function) fnglobalExecution pubsub (see below)invokeGlobalExecution
(ANY) eventglobalExecutionsubscribeToPage
(Page | string) page(function) fnPagepublishForPage
(Page | string) page(AND) eventPageonApplicationDidAppear
onApplicationDidLoad
document is readyonApplicationIsReady
onPageDidChange
refresh, forward, backwardonLocationHashChanged
location.hash is changedonApplicationDidUnload
onApplicationDidDisappear
onApplicationDidReceiveMemoryWarning
globalExecution
saveOnUnload
onApplicationDidDisappear - if changed to return a (string) a warning box will appear and block all code execution
Monitors memory, page duration, and activity.
constructor
noneanalyze
(string) namestart and stop to handle page change requestsonMemoryWarning
noneinquiry
nonestart
nonestop
activePage, navigatedTo, viewTime, viewDuration, memoryUsage to views object
Sets up a promisified generatorFunction to contain and manage a code execution.
A contained code execution environment allows code passed in JSON to be executed without effecting other code in the window.
generator
(__generatorFunction__) gengenerator into a handled promise-like state for success and error handlinggenerator.container
(function) functoPromise
(object) objthunkToPromise
(function) fnfunction but it doesn't have "arguments".arrayToPromise
(array) objobjectToPromise
(object) objisPromise
(Anything) objthenableisGenerator
(Anything) objthenable and throwable because it must catch errorsisGeneratorFunction
(Anything) objgeneratorisObject
(Anything) objobj is a real object
Executes a string of code in a container.
constructor
Generatorsuccess
error

// TODO: Document Librarian

Containment is a simple try-catch function.
Surprisingly enough, it is about 93% MORE EFFICIENT to put only ONE try catch in your code and have try-catch functions passed in... who-da-thunk?
constructor
(object) flood
(function) try function to attempt(function) error function in the event of an error(function) finally function called regardless of the result(function) result function called with the result of trygetResult
nonetry OR calls result againgetError
nonestackTrace) of an attempted tryExample use case:
const containment = new Containment( {
try: () => {
const i = 123;
return i = 321;
},
error: e => {
console.error( 'error', e );
},
finally: () => {
console.log( 'finally' );
},
result: r => {
console.log( 'result', r );
}
} );
PubSub is a Publish-Subscribe class to register functions to a specific event.
constructor
(string) name of "topic"(array) subscribers List of subscribersisFunction
(ANY) fnfn is a functionaddSubscription
(function) fnsubscriberslistSubscribers
nonesubscriberspublish
(ANY) eventeventv0.1.7 - Added verbose flag for Arbiter loggingv0.1.6 - Added Cleansing for The Librarianv0.1.5 - Bug fixesv0.1.4 - Fixed page refreshing issues on unhandled pathsv0.1.3 - Fixed a few location issuesv0.1.2 - Fixed querystring-handlingv0.1.1 - Fixed deep-path-handlingv0.1.0 - Added Cleansing for Polyfill - universal-browser-supportv0.0.7 - Added The Librarian - still in progressv0.0.6 - Added PubSub class for publications on eventsv0.0.5 - Added separate page classv0.0.4 - Converted from loose files to a module, added The Monitorv0.0.3 - Added Generator and Executor for string-javascript executionv0.0.2 - Removed double request issue on preloaded pagesv0.0.1 - First CommitFAQs
The Arbiter is a HTML routing and analytics system for front-end applications and websites.
We found that the-arbiter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.