@code-o-mat/globals
v0.0.17
Published
Abstract Package to support CodeOMat series of apps.
Downloads
16
Maintainers
Readme
CodeOMat Globals:
Alpha: version 0.0.1x: March 3, 2018:
Release Notes:
Version 0.0.1 will be released to support the HistoryCache Component of the CodeOMat System. As future components are developed, future releases of this package will be releaded in tandem.
All CodeOMat packages will adhere to the same version numbers.
Common values and functions to support libraries in the CodeOMat system in the @code-o-mat namespace.
For the most part, this package is intended to be used as an abstract package... that is only by other CodeOMat packages.
All packages in the CodeOMat namespace are currently experimental. Please use with Caution. In the future, this library will become better documented.
About CodeOMat
CodeOMat is a Meta Programming library that intends to make coding more concise, simpler and easier to read and learn.
installation
npm install @code-o-mat/globals
Globals Components:
Cache:
Cache is a data object used to store properties of the OMat type objects in CodeOMat. This is a wrapper for a plain JavaScript object. Its use here is to maintain compatibility with more advanced properties caches such as HistoryCache that may be used in some OMat types but which may not be needed for others.
Each OMat has a Cache located at oMat[PROPS], where PROPS is a symbol imported from this library at constants/values.
The API for Cache is similar to the API for Immutable Map, but does not access deeply nested properties.
instantiation:
const cache = new Cache([some data object]);
get a value at key with a fallback defaultValue:
cache.get(key, defaultValue);
set a value at key:
cache.set(key, value);
get the entire underlying JavaScript data object:
cache.data();
merge a new data object: ( shallow merge ): Items in the new data will override the existing data where keys match.
cache.merge(newDataObject);
Constants:
A series of constant values that will be used throughout the CodeOMat system. These are often used to allow pseudo - private function and attribute behaviors.
types:
These are Symbol objects that are attached to all CodeOMat objects as both instance and static values. They are used to identify the objects for validations and testing.
The types are:
O_MAT, METHOD_O_MAT, ACCESSOR_O_MAT, CONNECTOR_O_MAT, CLASS_O_MAT
values:
A set of values used by this library.
- NONE: used to avoid typical .js null values which may interfere with some desired accessor function.
- PROPS: internal properties of CodeOMat classes.
methods:
There are Symbols that represent methods in some of the CodeOMat objects. They are used to enforce a common function naming convention for non public methods.
Assertions & validations:
Assertions are available for some basic javascript types and also for OMat types.
All use the basic assert function of assert.
import { assert } from '@globals/assertions/base-assertions';
assert(1 === 1, 'An assert message'); // nothing happens.
assert(1 === 2, 'An assert message'); // throws new Error('An assert message');
js-types
Assertions for basic javascript types. All have a default error message that can be overridden with the an optional second parameter.
There is no separate set of validations for js-types as these are native to javascript.
OMat types
Assertions for basic javascript types. All have a default error message that can be overridden with the an optional second parameter.
All OMat type assertions will test instances and classes
- isOMat: As OMat is an abstract type, will return true for any number of OMat types.
VALIDATIONS:
- isMethodOMat:
isMethodOMat(methodOMat)
- isAccessorOMat:
isAccessorOMat(methodOMat)
- isConnectorOMat:
isConnectorOMat(methodOMat)
- isClassOMat:
isClassOMat(methodOMat)
- isCodeOMat:
isCodeOMat(methodOMat)
ASSERTIONS:
assertIsMethodOMat:
assertIsMethodOMat(methodOMat, "optional message")
assertIsMethodOMatOrNONE:
assertIsMethodOMatOrNONE(methodOMat, "optional message")
assertIsAccessorOMat:
assertIsAccessorOMat(methodOMat, "optional message")
assertIsAccessorOMatOrNONE:
assertIsAccessorOMatOrNONE(methodOMat, "optional message")
assertIsConnectorOMat:
assertIsConnectorOMat(methodOMat, "optional message")
assertIsConnectorOMatOrNONE:
assertIsConnectorOMatOrNONE(methodOMat, "optional message")
assertIsClassOMatOrNONE:
assertIsClassOMatorNONE(methodOMat, "optional message")
assertIsCodeOMat:
assertIsCodeOMat(methodOMat, "optional message")
assertIsCodeOMatOrNONE:
assertIsCodeOMatOrNONE(methodOMat, "optional message")