UNPKG

cutls

Version:

Some JavaScript util functions.

3 lines (2 loc) • 1.04 kB
// https://github.com/cedoor/cutls v0.1.6 Copyright 2019 Omar Desogus. !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).cutls=e.cutls||{})}(this,function(e){"use strict";function t(e){if("string"!=typeof e)throw TypeError("Parameter must be a string.");return e.charAt(0).toUpperCase()+e.toLowerCase().slice(1)}var r={capitalize:t,capitalizeList:function(e){if(!Array.isArray(e)||!e.every(function(e){return"string"==typeof e}))throw TypeError("Parameter must be an array of strings.");return e.map(t)}};var o={download:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"text/json",o=document.createElement("a"),n=new Blob([t],{type:r});o.href=window.URL.createObjectURL(n),o.download=e,o.dataset.downloadurl=[r,o.download,o.href].join(":"),o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o)}};e.file=o,e.strings=r,Object.defineProperty(e,"__esModule",{value:!0})});