pathington
Version:
Custom identity functions for composability
50 lines (43 loc) • 964 B
JavaScript
/**
* @constant {Object} CACHE
*
* @property {function} clear clear the cache results
* @property {Object} results the map of path => array results
* @property {number} size the size of the cache
*/
export var CACHE = {
clear: function clear() {
CACHE.results = {};
CACHE.size = 0;
},
results: {},
size: 0
};
/**
* @constant {RegExp} DOTTY_WITH_BRACKETS_SYNTAX
*/
export var DOTTY_WITH_BRACKETS_SYNTAX = /"[^"]+"|`[^`]+`|'[^']+'|[^.[\]]+/g;
/**
* @constant {number} MAX_CACHE_SIZE
*/
export var MAX_CACHE_SIZE = 500;
/**
* @constant {RegExp} NUMBER
*/
export var NUMBER = /^\d+$/i;
/**
* @constant {RegExp} QUOTED_KEY
*/
export var QUOTED_KEY = /^"[^"]+"|`[^`]+`|'[^']+'$/;
/**
* @constant {Array<string>} VALID_QUOTES
*/
export var VALID_QUOTES = /^["'`]{1}$/;
/**
* @constant {RegExp} VALID_KEY
*/
export var VALID_KEY = /^\d+$|^[a-zA-Z_$][\w$]+$/;
/**
* @constant {RegExp} WHITE_SPACE
*/
export var WHITE_SPACE = /\s/;