Download pool/shard003/JavaScript/0018996_test-utils.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 1.52 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard003/JavaScript/0018996_test-utils.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard003/JavaScript/0018996_test-utils.js
-
curl -L -o 0018996_test-utils.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard003/JavaScript/0018996_test-utils.js
1.52 kB
| ; | |
| module.exports = { | |
| /** | |
| * Creates an event. | |
| * @param {string} name - The event name | |
| * @param {object} [options] - Options to be passed to event | |
| */ | |
| createEvent: function (name, options) { | |
| let event; | |
| options = options || {}; | |
| options.bubbles = options.bubbles || true; | |
| options.cancelable = options.cancelable|| true; | |
| event = document.createEvent('CustomEvent'); | |
| event.initCustomEvent(name, options.bubbles, options.cancelable, null); | |
| return event; | |
| }, | |
| /** | |
| * Creates an HTML Element from an html string. | |
| * @param {string} html - String of html | |
| * @returns {HTMLElement} - Returns and html element node | |
| */ | |
| createHtmlElement: function (html) { | |
| let tempParentEl, | |
| el; | |
| if (html) { | |
| html = this.trim(html); | |
| tempParentEl = document.createElement('div'); | |
| tempParentEl.innerHTML = html; | |
| el = tempParentEl.childNodes[0]; | |
| return tempParentEl.removeChild(el); | |
| } | |
| }, | |
| /** | |
| * Zaps whitespace from both ends of a string. | |
| * @param {string} val - The string value to trim | |
| * @returns {string} Returns a trimmed string | |
| */ | |
| trim: function (val) { | |
| if (!String.prototype.trim) { | |
| String.prototype.trim = function () { | |
| return val.replace(/^\s+|\s+$/g, ''); | |
| }; | |
| } else { | |
| val = val.trim(); | |
| } | |
| return val; | |
| } | |
| }; | |