vocabulary.js (beta)
What makes the Wu Tang Clan so special? It's a combination of their style, creativity, intelligence, and especially their vocabulary. The amazing depth of word choice makes them the ultimate in expressiveness.
vocabulary.js is an attempt at a similar elegance. It's a library that turns common and ubiquitous Javascript logic into tiny, re-usable functions. Don't bother memorizing implementations or searching Stack Overflow - just learn the function names.
# of functions: 104
How is this different than lodash or Underscore?
If lodash and Underscore are utility belts, then vocabulary.js is like a team of Batmans wearing utility belts.
Usage
Using ES6 destructuring and module syntax:
const focusFirstFormField redirect isEscapeKeyEvent = ;
If you don't want the whole library, feel free to copy and paste the functions from the source!
Giant List of Functions
isNullisNotNullisEmptyisNotEmptyisNullOrEmptyisNotNullOrEmptyisPositiveisNegativeisZeroisSingularisPluralisEvenisOddisTrueisFalseisValidDateisEscapeKeyEventisEnterKeyEventisNodeListisStringisObjectisFunctionisArrayhasLeadingForwardSlashhasTrailingForwardSlashisLinkCurrentRoutetoListtoHtmlIdtoHtmlClasstoCamelCasetoMoneyStringtoHexStringtoHexNumbertoAsciiCodetoObjecttoPrettyJsontoUniqueArraytoEscapedHtmltoUnescapedHtmltoQueryStringfirstsecondlastincrementdecrementtrimcapitalizequeryappendTrailingSlashnewObjectgenerateRandomNumberrandomminmaxclonegroupgetInremovePhraseaddsubtractandororFalseorZeroorEmptyStringorEmptyArrayorEmptyObjectjoinBySpacejoinByNewLinejoinByCommaSpacesplitBySpacesplitByNewLinesplitByCommasplitByCommaSpacegetTypegetButtonsgetDropdownsgetInputsgetHtmlInputValuegetElementNamegetQueryStringRawgetQueryStringPairsgetQueryStringValuegetSelectedDropdownOptionaddClassremoveClasstoggleClasssetAttributescreateNodefocusFirstFormFieldifNotNullifNullthrowIfNulltryCatchshuffleInPlaceclearDropdownOptionsremovePropertyremoveElementdisableElementenableElementredirectdebugenableEs6enableJsxnoop
Browser Support
Most functions should work in IE 9 or above. No attempt was made to make the library work in IE 8 or below.
Tests
Run node tests
.
Contributing
Pull requests welcome! Please add unit tests to tests.js
for any new functions.
Dependencies
None, unless you use one of the handful of functions that have external depedencies: enableEs6
and enableJsx
Versions
Beta - missing: API documentation, examples, consistent naming of functions, organization, and structure (maybe beta is an optimistic word)