compound-subject
Version:
A tiny JavaScript library for converting arrays of strings to compound subjects
3 lines (2 loc) • 717 B
JavaScript
/*! compound-subject 2017-02-27 */
!function(){"use strict";var a=function(a){var b={},c="and",d=!1,e=",";return b.endWith=function(a){return"string"!=typeof a?b:(c=a,b)},b.delimitAll=function(){var a=arguments[0];return d="boolean"!=typeof a||a,b},b.delimitWith=function(a){return"string"!=typeof a?b:(e=a,b)},b.make=function(){if("undefined"==typeof a||!a instanceof Array)return"";var f,g,b=d&&a.length>2?e+" "+c+" ":" "+c+" ";return f=a.slice(0,-2).join(e+" "),g=a.slice(a.length-2).join(b),f.length?f+e+" "+g:g},b};if("undefined"!=typeof module)module.exports=a;else{if("undefined"==typeof window)throw new Error("Couldn't find a suitable scope in which to define compoundSubject");window.compoundSubject=a}}();