Package Exports
- @mypreview/unicorn-js-utils
- @mypreview/unicorn-js-utils/build/index.js
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 (@mypreview/unicorn-js-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Unicorn JS Utils
A collection of JavaScript utility methods delivering modularity, performance & extras.
Installation
Install the module
npm install @mypreview/unicorn-js-utils --save
Table of Content
Method | Description |
---|---|
backgroundImageStyle | Generate inline background-image CSS style based on provided URL |
blockClassName | Extracts block specific CSS class name generated by Gutenberg editor |
blockStyleSlug | Extracts selected block style slug from the provided block specific CSS class names |
booleanToString | Converts a bool to a yes or no |
deepPick | Creates an object composed of the (nested) picked object properties |
dimRatioClassName | Generate dim CSS class name based on the provided ratio or opacity |
filterCollectionByPredicate | Iterates over elements of input and returns all entries from collection for which predicate returns truthy. |
focalPointStyle | Generates corresponding CSS based on the provided focal point picker values |
formattedContent | Gets a formatted version of the post content provided |
getMailTo | Extracts email addresses from mailto href link |
hexToEmoji | Converts a given hex-unicode into an Emoji icon |
ifArray | Check if value is classified as an array object and is not empty |
insertAtIndex | Insert an item into an array at a specific index |
isPositionCenter | Determine whether the content is center positioned |
jsonify | Parses a JSON string, constructing the JavaScript value or object described by the string |
mode | Determines which element has the highest occurrence (mode) in the given array |
normalizeJsonify | Validate and normalize JSON string to an array |
positionToClassName | Generates content-position CSS class name based on provided input |
removeAtIndex | Removes an item from the array at a specific index |
sanitizeSlug | Sanitizes the slug value |
selectOptions | Generates an array of objects to be passed to the SelectControl component |
shortcode | Generate shortcode |
slugify | Slugifies every string, even when it contains unicode! |
spaceToNbsp | Converts empty spaces to its corresponsding HTML character entity |
stringify | Converts a JavaScript object or value to a JSON string |
stringifyQuery | Stringify an array of objects into a query string |
stringToBoolean | Converts a string (e.g. 'yes' or 'no') to a bool |