Package Exports
- @t7/utils
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@t7/utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
utils
"utils" is a collection of utilities that have been currated from multiple projects to perform simple targeted tasks.
The entire library can be imported (import utils from 'utils'
) or individual utilities can be imported as needed to keep production code bases as small as possible (import { ajax, log } from 'utils'
).
Available utilities:
bind: bind is a ReactJs specific utility that will bind all inline functions withing a module to the "this" context.
eg.utils.bind()
vsmyfunction = this.myfunction.bind(this)
convert_content-editable: dynaically applies the
contentEditable
attribute to an HTML elementconvert_content_focused: converts text, when "content editable" is focused
convert_on_paste: converts text to
contentEditable
format when pasted from clipboardconvert_to_markup: converts plain text received from an API call for use in a
contentEditable
areaconvert_to_text: convert innerHTML content to plain text
exists: verifies that a
variable
exists (is not equal toundefined
ornull
)log: a helper function for
console.log
(especially usefull if linting rules forbid the use ofconsole.log
)navigate: method for navigating React routes
eg.utils.navigate([ 'users', userId, 'items', itemId ])
parse_form_data: Parses all inputs in a
<form>
and returns a formatted objectpath: generate React routes
eg.const url = utils.path(['users', userId, 'items', itemId
placeholder: a "faux" placeholder
regex: a helper function to "escape" a string or an array of strings
save: allows you to save data as a
console.json
file (similar tonpm
packageconsole.json
)stop: calls
preventDefault
andstopPropagation
for event callback functionsstorage: provides
get
,set
andclear
functions forlocalStorage
title: dynamically constructs/assignes a page title
today: returns 1 day, in milliseconds
trim: helper for JavaScript
trim
function (ensures that the value is a valid string)unique: helper to return a unique string (useful for generating unique keys)