A collection of Javascript helper functions used by several Eluvio libraries.
THIS LIBRARY IS CURRENTLY IN PRE-RELEASE: FUNCTION NAMES AND SIGNATURES ARE STILL IN FLUX.
https://eluv-io.github.io/elv-js-helpers/api.html
npm install --save @eluvio/elv-js-helpers
It is possible to import individual items or the entire library, depending on whether code size is a concern.
// namespace entire suite to a const
const H = require('@eluvio/elv-js-helpers')
console.log(H.Datetime.now())
// create references to particular items in order to avoid needing to use H.Category prefix
const { etaDurStr, etaTimeStr } = H.Datetime
const {_boundLowerErrMsg} = H.ModelAssertion
// Get reference to 1 category (note that this will still wind up incuding the entire package)
const { Datetime } = require('@eluvio/elv-js-helpers')
console.log(Datetime.now())
// namespace entire suite to H
import H from '@eluvio/elv-js-helpers'
// create references to particular items in order to avoid needing to use H. prefix
const { etaDurStr, etaTimeStr } = H.Datetime
const {_boundLowerErrMsg} = H.ModelAssertion
// Note that the following syntax still causes entire library to be bundled into your project
import { Datetime } from '@eluvio/elv-js-helpers'
Importing individual items will minimize code size.
// require in each item directly
const etaDurStr = require('@eluvio/elv-js-helpers/Datetime/etaDurStr')
const etaTimeStr = require('@eluvio/elv-js-helpers/Datetime/etaTimeStr')
const _boundLowerErrMsg = require('@eluvio/elv-js-helpers/ModelAssertion/_boundLowerErrMsg')
// import in each item directly
import etaDurStr from '@eluvio/elv-js-helpers/Datetime/etaDurStr'
import etaTimeStr from '@eluvio/elv-js-helpers/Datetime/etaTimeStr'
import _boundLowerErrMsg from '@eluvio/elv-js-helpers/ModelAssertion/_boundLowerErrMsg'
Although not recommended, it is also possible to import the entire library directly into a browser via a <script>
tag
pointing to a copy of either dist/elv-js-helpers.js
or dist/elv-js-helpers.min.js
. This will create a variable named
ElvJsHelpers
in the global namespace. There is no support for importing individual items via a <script>
tag. (It
is expected that browser apps would be built using a bundling tool like Webpack/Rollup/Parcel)
<!-- Import entire library as ElvJsHelper -->
<script src="elv-js-helpers.js"></script>
<script type="application/javascript">
console.log('System locale is: ' + ElvJsHelpers.Datetime.sysLocale())
console.log('_boundLowerErrMsg(0,true)= "' + ElvJsHelpers.ModelAssertion._boundLowerErrMsg(0,true) + '"')
</script>
src/CATEGORY/*.js
).js
extension added)src/
according to category (1 category per subdirectory)conditionalCheck
not condlChk
(function)sysTimezone
not sysTZ
(function)assertPropMaxGTEMin
not assertPropertyMaximumGreaterThanOrEqualToMinimum
(function)defNonEmptyArrModel
not defineNonEmptyArrayModel
(function)RE_UTC_TIMESTAMP
not REGEXP_UNIVERSAL_TIME_COORDINATED_TIMESTAMP
(constant)ADT
not AlgebraicDataType
(category)resultToPOJO
not resultToPlainOldJavascriptObject
(function)Datetime
not DateTime
(category)sysTimezone
not sysTimeZone
(function)RE_UTC_TIMESTAMP
not RE_UTC_TIME_STAMP
(constant)ADT
not Adt
(category)parseUTCStr
not parseUtcStr
(function)utcStrToDate
not uTCStrToDate
(function)etaDurStr
not eTADurStr
(function)NonBlankStrModel
not NonblankStrModel
(model)wrapNonArray
not wrapNonarray
(function)List
, Ok
)ModelAssertion
, ModelFactory
)RE_UTC_TIMESTAMP
)
NonBlankStrModel
)
mapWithIndex
, resultUnwrap
)
defArrModel
, defObjModel
)_boundLowerErrMsg
)Show private
is checked.