UNPKG

dropkiq

Version:

Liquid Expressions Simplified

1 lines 1.57 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var underscore_1=require("../../util/underscore");function capitalize(r){return(r=underscore_1.stringify(r)).charAt(0).toUpperCase()+r.slice(1)}function replace(r,e,n){return underscore_1.stringify(r).split(e).join(n)}function replaceFirst(r,e,n){return underscore_1.stringify(r).replace(e,n)}function truncate(r,e,n){return void 0===e&&(e=50),void 0===n&&(n="..."),(r=underscore_1.stringify(r)).length<=e?r:r.substr(0,e-n.length)+n}function truncateWords(r,e,n){void 0===e&&(e=15),void 0===n&&(n="...");var t=r.split(/\s+/),i=t.slice(0,e).join(" ");return t.length>=e&&(i+=n),i}exports.default={append:function(r,e){return underscore_1.stringify(r)+underscore_1.stringify(e)},prepend:function(r,e){return underscore_1.stringify(e)+underscore_1.stringify(r)},capitalize:capitalize,lstrip:function(r){return underscore_1.stringify(r).replace(/^\s+/,"")},downcase:function(r){return underscore_1.stringify(r).toLowerCase()},upcase:function(r){return underscore_1.stringify(r).toUpperCase()},remove:function(r,e){return underscore_1.stringify(r).split(e).join("")},remove_first:function(r,e){return underscore_1.stringify(r).replace(e,"")},replace:replace,replace_first:replaceFirst,rstrip:function(r){return underscore_1.stringify(r).replace(/\s+$/,"")},split:function(r,e){return underscore_1.stringify(r).split(e)},strip:function(r){return underscore_1.stringify(r).trim()},strip_newlines:function(r){return underscore_1.stringify(r).replace(/\n/g,"")},truncate:truncate,truncatewords:truncateWords};