plist-build.js 119 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982
  1. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.plist = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. (function (Buffer){
  3. /**
  4. * Module dependencies.
  5. */
  6. var base64 = require('base64-js');
  7. var xmlbuilder = require('xmlbuilder');
  8. /**
  9. * Module exports.
  10. */
  11. exports.build = build;
  12. /**
  13. * Accepts a `Date` instance and returns an ISO date string.
  14. *
  15. * @param {Date} d - Date instance to serialize
  16. * @returns {String} ISO date string representation of `d`
  17. * @api private
  18. */
  19. function ISODateString(d){
  20. function pad(n){
  21. return n < 10 ? '0' + n : n;
  22. }
  23. return d.getUTCFullYear()+'-'
  24. + pad(d.getUTCMonth()+1)+'-'
  25. + pad(d.getUTCDate())+'T'
  26. + pad(d.getUTCHours())+':'
  27. + pad(d.getUTCMinutes())+':'
  28. + pad(d.getUTCSeconds())+'Z';
  29. }
  30. /**
  31. * Returns the internal "type" of `obj` via the
  32. * `Object.prototype.toString()` trick.
  33. *
  34. * @param {Mixed} obj - any value
  35. * @returns {String} the internal "type" name
  36. * @api private
  37. */
  38. var toString = Object.prototype.toString;
  39. function type (obj) {
  40. var m = toString.call(obj).match(/\[object (.*)\]/);
  41. return m ? m[1] : m;
  42. }
  43. /**
  44. * Generate an XML plist string from the input object `obj`.
  45. *
  46. * @param {Object} obj - the object to convert
  47. * @param {Object} [opts] - optional options object
  48. * @returns {String} converted plist XML string
  49. * @api public
  50. */
  51. function build (obj, opts) {
  52. var XMLHDR = {
  53. version: '1.0',
  54. encoding: 'UTF-8'
  55. };
  56. var XMLDTD = {
  57. pubid: '-//Apple//DTD PLIST 1.0//EN',
  58. sysid: 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'
  59. };
  60. var doc = xmlbuilder.create('plist');
  61. doc.dec(XMLHDR.version, XMLHDR.encoding, XMLHDR.standalone);
  62. doc.dtd(XMLDTD.pubid, XMLDTD.sysid);
  63. doc.att('version', '1.0');
  64. walk_obj(obj, doc);
  65. if (!opts) opts = {};
  66. // default `pretty` to `true`
  67. opts.pretty = opts.pretty !== false;
  68. return doc.end(opts);
  69. }
  70. /**
  71. * depth first, recursive traversal of a javascript object. when complete,
  72. * next_child contains a reference to the build XML object.
  73. *
  74. * @api private
  75. */
  76. function walk_obj(next, next_child) {
  77. var tag_type, i, prop;
  78. var name = type(next);
  79. if ('Undefined' == name) {
  80. return;
  81. } else if (Array.isArray(next)) {
  82. next_child = next_child.ele('array');
  83. for (i = 0; i < next.length; i++) {
  84. walk_obj(next[i], next_child);
  85. }
  86. } else if (Buffer.isBuffer(next)) {
  87. next_child.ele('data').raw(next.toString('base64'));
  88. } else if ('Object' == name) {
  89. next_child = next_child.ele('dict');
  90. for (prop in next) {
  91. if (next.hasOwnProperty(prop)) {
  92. next_child.ele('key').txt(prop);
  93. walk_obj(next[prop], next_child);
  94. }
  95. }
  96. } else if ('Number' == name) {
  97. // detect if this is an integer or real
  98. // TODO: add an ability to force one way or another via a "cast"
  99. tag_type = (next % 1 === 0) ? 'integer' : 'real';
  100. next_child.ele(tag_type).txt(next.toString());
  101. } else if ('Date' == name) {
  102. next_child.ele('date').txt(ISODateString(new Date(next)));
  103. } else if ('Boolean' == name) {
  104. next_child.ele(next ? 'true' : 'false');
  105. } else if ('String' == name) {
  106. next_child.ele('string').txt(next);
  107. } else if ('ArrayBuffer' == name) {
  108. next_child.ele('data').raw(base64.fromByteArray(next));
  109. } else if (next && next.buffer && 'ArrayBuffer' == type(next.buffer)) {
  110. // a typed array
  111. next_child.ele('data').raw(base64.fromByteArray(new Uint8Array(next.buffer), next_child));
  112. }
  113. }
  114. }).call(this,{"isBuffer":require("../node_modules/is-buffer/index.js")})
  115. },{"../node_modules/is-buffer/index.js":3,"base64-js":2,"xmlbuilder":79}],2:[function(require,module,exports){
  116. var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  117. ;(function (exports) {
  118. 'use strict';
  119. var Arr = (typeof Uint8Array !== 'undefined')
  120. ? Uint8Array
  121. : Array
  122. var PLUS = '+'.charCodeAt(0)
  123. var SLASH = '/'.charCodeAt(0)
  124. var NUMBER = '0'.charCodeAt(0)
  125. var LOWER = 'a'.charCodeAt(0)
  126. var UPPER = 'A'.charCodeAt(0)
  127. var PLUS_URL_SAFE = '-'.charCodeAt(0)
  128. var SLASH_URL_SAFE = '_'.charCodeAt(0)
  129. function decode (elt) {
  130. var code = elt.charCodeAt(0)
  131. if (code === PLUS ||
  132. code === PLUS_URL_SAFE)
  133. return 62 // '+'
  134. if (code === SLASH ||
  135. code === SLASH_URL_SAFE)
  136. return 63 // '/'
  137. if (code < NUMBER)
  138. return -1 //no match
  139. if (code < NUMBER + 10)
  140. return code - NUMBER + 26 + 26
  141. if (code < UPPER + 26)
  142. return code - UPPER
  143. if (code < LOWER + 26)
  144. return code - LOWER + 26
  145. }
  146. function b64ToByteArray (b64) {
  147. var i, j, l, tmp, placeHolders, arr
  148. if (b64.length % 4 > 0) {
  149. throw new Error('Invalid string. Length must be a multiple of 4')
  150. }
  151. // the number of equal signs (place holders)
  152. // if there are two placeholders, than the two characters before it
  153. // represent one byte
  154. // if there is only one, then the three characters before it represent 2 bytes
  155. // this is just a cheap hack to not do indexOf twice
  156. var len = b64.length
  157. placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
  158. // base64 is 4/3 + up to two characters of the original data
  159. arr = new Arr(b64.length * 3 / 4 - placeHolders)
  160. // if there are placeholders, only get up to the last complete 4 chars
  161. l = placeHolders > 0 ? b64.length - 4 : b64.length
  162. var L = 0
  163. function push (v) {
  164. arr[L++] = v
  165. }
  166. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  167. tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
  168. push((tmp & 0xFF0000) >> 16)
  169. push((tmp & 0xFF00) >> 8)
  170. push(tmp & 0xFF)
  171. }
  172. if (placeHolders === 2) {
  173. tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
  174. push(tmp & 0xFF)
  175. } else if (placeHolders === 1) {
  176. tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
  177. push((tmp >> 8) & 0xFF)
  178. push(tmp & 0xFF)
  179. }
  180. return arr
  181. }
  182. function uint8ToBase64 (uint8) {
  183. var i,
  184. extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
  185. output = "",
  186. temp, length
  187. function encode (num) {
  188. return lookup.charAt(num)
  189. }
  190. function tripletToBase64 (num) {
  191. return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
  192. }
  193. // go through the array every three bytes, we'll deal with trailing stuff later
  194. for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
  195. temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
  196. output += tripletToBase64(temp)
  197. }
  198. // pad the end with zeros, but make sure to not forget the extra bytes
  199. switch (extraBytes) {
  200. case 1:
  201. temp = uint8[uint8.length - 1]
  202. output += encode(temp >> 2)
  203. output += encode((temp << 4) & 0x3F)
  204. output += '=='
  205. break
  206. case 2:
  207. temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
  208. output += encode(temp >> 10)
  209. output += encode((temp >> 4) & 0x3F)
  210. output += encode((temp << 2) & 0x3F)
  211. output += '='
  212. break
  213. }
  214. return output
  215. }
  216. exports.toByteArray = b64ToByteArray
  217. exports.fromByteArray = uint8ToBase64
  218. }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
  219. },{}],3:[function(require,module,exports){
  220. /**
  221. * Determine if an object is Buffer
  222. *
  223. * Author: Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  224. * License: MIT
  225. *
  226. * `npm install is-buffer`
  227. */
  228. module.exports = function (obj) {
  229. return !!(obj != null &&
  230. (obj._isBuffer || // For Safari 5-7 (missing Object.prototype.constructor)
  231. (obj.constructor &&
  232. typeof obj.constructor.isBuffer === 'function' &&
  233. obj.constructor.isBuffer(obj))
  234. ))
  235. }
  236. },{}],4:[function(require,module,exports){
  237. /**
  238. * Gets the last element of `array`.
  239. *
  240. * @static
  241. * @memberOf _
  242. * @category Array
  243. * @param {Array} array The array to query.
  244. * @returns {*} Returns the last element of `array`.
  245. * @example
  246. *
  247. * _.last([1, 2, 3]);
  248. * // => 3
  249. */
  250. function last(array) {
  251. var length = array ? array.length : 0;
  252. return length ? array[length - 1] : undefined;
  253. }
  254. module.exports = last;
  255. },{}],5:[function(require,module,exports){
  256. var arrayEvery = require('../internal/arrayEvery'),
  257. baseCallback = require('../internal/baseCallback'),
  258. baseEvery = require('../internal/baseEvery'),
  259. isArray = require('../lang/isArray'),
  260. isIterateeCall = require('../internal/isIterateeCall');
  261. /**
  262. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  263. * The predicate is bound to `thisArg` and invoked with three arguments:
  264. * (value, index|key, collection).
  265. *
  266. * If a property name is provided for `predicate` the created `_.property`
  267. * style callback returns the property value of the given element.
  268. *
  269. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  270. * style callback returns `true` for elements that have a matching property
  271. * value, else `false`.
  272. *
  273. * If an object is provided for `predicate` the created `_.matches` style
  274. * callback returns `true` for elements that have the properties of the given
  275. * object, else `false`.
  276. *
  277. * @static
  278. * @memberOf _
  279. * @alias all
  280. * @category Collection
  281. * @param {Array|Object|string} collection The collection to iterate over.
  282. * @param {Function|Object|string} [predicate=_.identity] The function invoked
  283. * per iteration.
  284. * @param {*} [thisArg] The `this` binding of `predicate`.
  285. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  286. * else `false`.
  287. * @example
  288. *
  289. * _.every([true, 1, null, 'yes'], Boolean);
  290. * // => false
  291. *
  292. * var users = [
  293. * { 'user': 'barney', 'active': false },
  294. * { 'user': 'fred', 'active': false }
  295. * ];
  296. *
  297. * // using the `_.matches` callback shorthand
  298. * _.every(users, { 'user': 'barney', 'active': false });
  299. * // => false
  300. *
  301. * // using the `_.matchesProperty` callback shorthand
  302. * _.every(users, 'active', false);
  303. * // => true
  304. *
  305. * // using the `_.property` callback shorthand
  306. * _.every(users, 'active');
  307. * // => false
  308. */
  309. function every(collection, predicate, thisArg) {
  310. var func = isArray(collection) ? arrayEvery : baseEvery;
  311. if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
  312. predicate = undefined;
  313. }
  314. if (typeof predicate != 'function' || thisArg !== undefined) {
  315. predicate = baseCallback(predicate, thisArg, 3);
  316. }
  317. return func(collection, predicate);
  318. }
  319. module.exports = every;
  320. },{"../internal/arrayEvery":7,"../internal/baseCallback":11,"../internal/baseEvery":15,"../internal/isIterateeCall":40,"../lang/isArray":49}],6:[function(require,module,exports){
  321. /** Used as the `TypeError` message for "Functions" methods. */
  322. var FUNC_ERROR_TEXT = 'Expected a function';
  323. /* Native method references for those with the same name as other `lodash` methods. */
  324. var nativeMax = Math.max;
  325. /**
  326. * Creates a function that invokes `func` with the `this` binding of the
  327. * created function and arguments from `start` and beyond provided as an array.
  328. *
  329. * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/Web/JavaScript/Reference/Functions/rest_parameters).
  330. *
  331. * @static
  332. * @memberOf _
  333. * @category Function
  334. * @param {Function} func The function to apply a rest parameter to.
  335. * @param {number} [start=func.length-1] The start position of the rest parameter.
  336. * @returns {Function} Returns the new function.
  337. * @example
  338. *
  339. * var say = _.restParam(function(what, names) {
  340. * return what + ' ' + _.initial(names).join(', ') +
  341. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  342. * });
  343. *
  344. * say('hello', 'fred', 'barney', 'pebbles');
  345. * // => 'hello fred, barney, & pebbles'
  346. */
  347. function restParam(func, start) {
  348. if (typeof func != 'function') {
  349. throw new TypeError(FUNC_ERROR_TEXT);
  350. }
  351. start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
  352. return function() {
  353. var args = arguments,
  354. index = -1,
  355. length = nativeMax(args.length - start, 0),
  356. rest = Array(length);
  357. while (++index < length) {
  358. rest[index] = args[start + index];
  359. }
  360. switch (start) {
  361. case 0: return func.call(this, rest);
  362. case 1: return func.call(this, args[0], rest);
  363. case 2: return func.call(this, args[0], args[1], rest);
  364. }
  365. var otherArgs = Array(start + 1);
  366. index = -1;
  367. while (++index < start) {
  368. otherArgs[index] = args[index];
  369. }
  370. otherArgs[start] = rest;
  371. return func.apply(this, otherArgs);
  372. };
  373. }
  374. module.exports = restParam;
  375. },{}],7:[function(require,module,exports){
  376. /**
  377. * A specialized version of `_.every` for arrays without support for callback
  378. * shorthands and `this` binding.
  379. *
  380. * @private
  381. * @param {Array} array The array to iterate over.
  382. * @param {Function} predicate The function invoked per iteration.
  383. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  384. * else `false`.
  385. */
  386. function arrayEvery(array, predicate) {
  387. var index = -1,
  388. length = array.length;
  389. while (++index < length) {
  390. if (!predicate(array[index], index, array)) {
  391. return false;
  392. }
  393. }
  394. return true;
  395. }
  396. module.exports = arrayEvery;
  397. },{}],8:[function(require,module,exports){
  398. /**
  399. * A specialized version of `_.some` for arrays without support for callback
  400. * shorthands and `this` binding.
  401. *
  402. * @private
  403. * @param {Array} array The array to iterate over.
  404. * @param {Function} predicate The function invoked per iteration.
  405. * @returns {boolean} Returns `true` if any element passes the predicate check,
  406. * else `false`.
  407. */
  408. function arraySome(array, predicate) {
  409. var index = -1,
  410. length = array.length;
  411. while (++index < length) {
  412. if (predicate(array[index], index, array)) {
  413. return true;
  414. }
  415. }
  416. return false;
  417. }
  418. module.exports = arraySome;
  419. },{}],9:[function(require,module,exports){
  420. var keys = require('../object/keys');
  421. /**
  422. * A specialized version of `_.assign` for customizing assigned values without
  423. * support for argument juggling, multiple sources, and `this` binding `customizer`
  424. * functions.
  425. *
  426. * @private
  427. * @param {Object} object The destination object.
  428. * @param {Object} source The source object.
  429. * @param {Function} customizer The function to customize assigned values.
  430. * @returns {Object} Returns `object`.
  431. */
  432. function assignWith(object, source, customizer) {
  433. var index = -1,
  434. props = keys(source),
  435. length = props.length;
  436. while (++index < length) {
  437. var key = props[index],
  438. value = object[key],
  439. result = customizer(value, source[key], key, object, source);
  440. if ((result === result ? (result !== value) : (value === value)) ||
  441. (value === undefined && !(key in object))) {
  442. object[key] = result;
  443. }
  444. }
  445. return object;
  446. }
  447. module.exports = assignWith;
  448. },{"../object/keys":58}],10:[function(require,module,exports){
  449. var baseCopy = require('./baseCopy'),
  450. keys = require('../object/keys');
  451. /**
  452. * The base implementation of `_.assign` without support for argument juggling,
  453. * multiple sources, and `customizer` functions.
  454. *
  455. * @private
  456. * @param {Object} object The destination object.
  457. * @param {Object} source The source object.
  458. * @returns {Object} Returns `object`.
  459. */
  460. function baseAssign(object, source) {
  461. return source == null
  462. ? object
  463. : baseCopy(source, keys(source), object);
  464. }
  465. module.exports = baseAssign;
  466. },{"../object/keys":58,"./baseCopy":12}],11:[function(require,module,exports){
  467. var baseMatches = require('./baseMatches'),
  468. baseMatchesProperty = require('./baseMatchesProperty'),
  469. bindCallback = require('./bindCallback'),
  470. identity = require('../utility/identity'),
  471. property = require('../utility/property');
  472. /**
  473. * The base implementation of `_.callback` which supports specifying the
  474. * number of arguments to provide to `func`.
  475. *
  476. * @private
  477. * @param {*} [func=_.identity] The value to convert to a callback.
  478. * @param {*} [thisArg] The `this` binding of `func`.
  479. * @param {number} [argCount] The number of arguments to provide to `func`.
  480. * @returns {Function} Returns the callback.
  481. */
  482. function baseCallback(func, thisArg, argCount) {
  483. var type = typeof func;
  484. if (type == 'function') {
  485. return thisArg === undefined
  486. ? func
  487. : bindCallback(func, thisArg, argCount);
  488. }
  489. if (func == null) {
  490. return identity;
  491. }
  492. if (type == 'object') {
  493. return baseMatches(func);
  494. }
  495. return thisArg === undefined
  496. ? property(func)
  497. : baseMatchesProperty(func, thisArg);
  498. }
  499. module.exports = baseCallback;
  500. },{"../utility/identity":61,"../utility/property":62,"./baseMatches":22,"./baseMatchesProperty":23,"./bindCallback":28}],12:[function(require,module,exports){
  501. /**
  502. * Copies properties of `source` to `object`.
  503. *
  504. * @private
  505. * @param {Object} source The object to copy properties from.
  506. * @param {Array} props The property names to copy.
  507. * @param {Object} [object={}] The object to copy properties to.
  508. * @returns {Object} Returns `object`.
  509. */
  510. function baseCopy(source, props, object) {
  511. object || (object = {});
  512. var index = -1,
  513. length = props.length;
  514. while (++index < length) {
  515. var key = props[index];
  516. object[key] = source[key];
  517. }
  518. return object;
  519. }
  520. module.exports = baseCopy;
  521. },{}],13:[function(require,module,exports){
  522. var isObject = require('../lang/isObject');
  523. /**
  524. * The base implementation of `_.create` without support for assigning
  525. * properties to the created object.
  526. *
  527. * @private
  528. * @param {Object} prototype The object to inherit from.
  529. * @returns {Object} Returns the new object.
  530. */
  531. var baseCreate = (function() {
  532. function object() {}
  533. return function(prototype) {
  534. if (isObject(prototype)) {
  535. object.prototype = prototype;
  536. var result = new object;
  537. object.prototype = undefined;
  538. }
  539. return result || {};
  540. };
  541. }());
  542. module.exports = baseCreate;
  543. },{"../lang/isObject":53}],14:[function(require,module,exports){
  544. var baseForOwn = require('./baseForOwn'),
  545. createBaseEach = require('./createBaseEach');
  546. /**
  547. * The base implementation of `_.forEach` without support for callback
  548. * shorthands and `this` binding.
  549. *
  550. * @private
  551. * @param {Array|Object|string} collection The collection to iterate over.
  552. * @param {Function} iteratee The function invoked per iteration.
  553. * @returns {Array|Object|string} Returns `collection`.
  554. */
  555. var baseEach = createBaseEach(baseForOwn);
  556. module.exports = baseEach;
  557. },{"./baseForOwn":17,"./createBaseEach":30}],15:[function(require,module,exports){
  558. var baseEach = require('./baseEach');
  559. /**
  560. * The base implementation of `_.every` without support for callback
  561. * shorthands and `this` binding.
  562. *
  563. * @private
  564. * @param {Array|Object|string} collection The collection to iterate over.
  565. * @param {Function} predicate The function invoked per iteration.
  566. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  567. * else `false`
  568. */
  569. function baseEvery(collection, predicate) {
  570. var result = true;
  571. baseEach(collection, function(value, index, collection) {
  572. result = !!predicate(value, index, collection);
  573. return result;
  574. });
  575. return result;
  576. }
  577. module.exports = baseEvery;
  578. },{"./baseEach":14}],16:[function(require,module,exports){
  579. var createBaseFor = require('./createBaseFor');
  580. /**
  581. * The base implementation of `baseForIn` and `baseForOwn` which iterates
  582. * over `object` properties returned by `keysFunc` invoking `iteratee` for
  583. * each property. Iteratee functions may exit iteration early by explicitly
  584. * returning `false`.
  585. *
  586. * @private
  587. * @param {Object} object The object to iterate over.
  588. * @param {Function} iteratee The function invoked per iteration.
  589. * @param {Function} keysFunc The function to get the keys of `object`.
  590. * @returns {Object} Returns `object`.
  591. */
  592. var baseFor = createBaseFor();
  593. module.exports = baseFor;
  594. },{"./createBaseFor":31}],17:[function(require,module,exports){
  595. var baseFor = require('./baseFor'),
  596. keys = require('../object/keys');
  597. /**
  598. * The base implementation of `_.forOwn` without support for callback
  599. * shorthands and `this` binding.
  600. *
  601. * @private
  602. * @param {Object} object The object to iterate over.
  603. * @param {Function} iteratee The function invoked per iteration.
  604. * @returns {Object} Returns `object`.
  605. */
  606. function baseForOwn(object, iteratee) {
  607. return baseFor(object, iteratee, keys);
  608. }
  609. module.exports = baseForOwn;
  610. },{"../object/keys":58,"./baseFor":16}],18:[function(require,module,exports){
  611. var toObject = require('./toObject');
  612. /**
  613. * The base implementation of `get` without support for string paths
  614. * and default values.
  615. *
  616. * @private
  617. * @param {Object} object The object to query.
  618. * @param {Array} path The path of the property to get.
  619. * @param {string} [pathKey] The key representation of path.
  620. * @returns {*} Returns the resolved value.
  621. */
  622. function baseGet(object, path, pathKey) {
  623. if (object == null) {
  624. return;
  625. }
  626. if (pathKey !== undefined && pathKey in toObject(object)) {
  627. path = [pathKey];
  628. }
  629. var index = 0,
  630. length = path.length;
  631. while (object != null && index < length) {
  632. object = object[path[index++]];
  633. }
  634. return (index && index == length) ? object : undefined;
  635. }
  636. module.exports = baseGet;
  637. },{"./toObject":46}],19:[function(require,module,exports){
  638. var baseIsEqualDeep = require('./baseIsEqualDeep'),
  639. isObject = require('../lang/isObject'),
  640. isObjectLike = require('./isObjectLike');
  641. /**
  642. * The base implementation of `_.isEqual` without support for `this` binding
  643. * `customizer` functions.
  644. *
  645. * @private
  646. * @param {*} value The value to compare.
  647. * @param {*} other The other value to compare.
  648. * @param {Function} [customizer] The function to customize comparing values.
  649. * @param {boolean} [isLoose] Specify performing partial comparisons.
  650. * @param {Array} [stackA] Tracks traversed `value` objects.
  651. * @param {Array} [stackB] Tracks traversed `other` objects.
  652. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  653. */
  654. function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
  655. if (value === other) {
  656. return true;
  657. }
  658. if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
  659. return value !== value && other !== other;
  660. }
  661. return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
  662. }
  663. module.exports = baseIsEqual;
  664. },{"../lang/isObject":53,"./baseIsEqualDeep":20,"./isObjectLike":43}],20:[function(require,module,exports){
  665. var equalArrays = require('./equalArrays'),
  666. equalByTag = require('./equalByTag'),
  667. equalObjects = require('./equalObjects'),
  668. isArray = require('../lang/isArray'),
  669. isTypedArray = require('../lang/isTypedArray');
  670. /** `Object#toString` result references. */
  671. var argsTag = '[object Arguments]',
  672. arrayTag = '[object Array]',
  673. objectTag = '[object Object]';
  674. /** Used for native method references. */
  675. var objectProto = Object.prototype;
  676. /** Used to check objects for own properties. */
  677. var hasOwnProperty = objectProto.hasOwnProperty;
  678. /**
  679. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  680. * of values.
  681. */
  682. var objToString = objectProto.toString;
  683. /**
  684. * A specialized version of `baseIsEqual` for arrays and objects which performs
  685. * deep comparisons and tracks traversed objects enabling objects with circular
  686. * references to be compared.
  687. *
  688. * @private
  689. * @param {Object} object The object to compare.
  690. * @param {Object} other The other object to compare.
  691. * @param {Function} equalFunc The function to determine equivalents of values.
  692. * @param {Function} [customizer] The function to customize comparing objects.
  693. * @param {boolean} [isLoose] Specify performing partial comparisons.
  694. * @param {Array} [stackA=[]] Tracks traversed `value` objects.
  695. * @param {Array} [stackB=[]] Tracks traversed `other` objects.
  696. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  697. */
  698. function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  699. var objIsArr = isArray(object),
  700. othIsArr = isArray(other),
  701. objTag = arrayTag,
  702. othTag = arrayTag;
  703. if (!objIsArr) {
  704. objTag = objToString.call(object);
  705. if (objTag == argsTag) {
  706. objTag = objectTag;
  707. } else if (objTag != objectTag) {
  708. objIsArr = isTypedArray(object);
  709. }
  710. }
  711. if (!othIsArr) {
  712. othTag = objToString.call(other);
  713. if (othTag == argsTag) {
  714. othTag = objectTag;
  715. } else if (othTag != objectTag) {
  716. othIsArr = isTypedArray(other);
  717. }
  718. }
  719. var objIsObj = objTag == objectTag,
  720. othIsObj = othTag == objectTag,
  721. isSameTag = objTag == othTag;
  722. if (isSameTag && !(objIsArr || objIsObj)) {
  723. return equalByTag(object, other, objTag);
  724. }
  725. if (!isLoose) {
  726. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  727. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  728. if (objIsWrapped || othIsWrapped) {
  729. return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
  730. }
  731. }
  732. if (!isSameTag) {
  733. return false;
  734. }
  735. // Assume cyclic values are equal.
  736. // For more information on detecting circular references see https://es5.github.io/#JO.
  737. stackA || (stackA = []);
  738. stackB || (stackB = []);
  739. var length = stackA.length;
  740. while (length--) {
  741. if (stackA[length] == object) {
  742. return stackB[length] == other;
  743. }
  744. }
  745. // Add `object` and `other` to the stack of traversed objects.
  746. stackA.push(object);
  747. stackB.push(other);
  748. var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
  749. stackA.pop();
  750. stackB.pop();
  751. return result;
  752. }
  753. module.exports = baseIsEqualDeep;
  754. },{"../lang/isArray":49,"../lang/isTypedArray":55,"./equalArrays":32,"./equalByTag":33,"./equalObjects":34}],21:[function(require,module,exports){
  755. var baseIsEqual = require('./baseIsEqual'),
  756. toObject = require('./toObject');
  757. /**
  758. * The base implementation of `_.isMatch` without support for callback
  759. * shorthands and `this` binding.
  760. *
  761. * @private
  762. * @param {Object} object The object to inspect.
  763. * @param {Array} matchData The propery names, values, and compare flags to match.
  764. * @param {Function} [customizer] The function to customize comparing objects.
  765. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  766. */
  767. function baseIsMatch(object, matchData, customizer) {
  768. var index = matchData.length,
  769. length = index,
  770. noCustomizer = !customizer;
  771. if (object == null) {
  772. return !length;
  773. }
  774. object = toObject(object);
  775. while (index--) {
  776. var data = matchData[index];
  777. if ((noCustomizer && data[2])
  778. ? data[1] !== object[data[0]]
  779. : !(data[0] in object)
  780. ) {
  781. return false;
  782. }
  783. }
  784. while (++index < length) {
  785. data = matchData[index];
  786. var key = data[0],
  787. objValue = object[key],
  788. srcValue = data[1];
  789. if (noCustomizer && data[2]) {
  790. if (objValue === undefined && !(key in object)) {
  791. return false;
  792. }
  793. } else {
  794. var result = customizer ? customizer(objValue, srcValue, key) : undefined;
  795. if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) {
  796. return false;
  797. }
  798. }
  799. }
  800. return true;
  801. }
  802. module.exports = baseIsMatch;
  803. },{"./baseIsEqual":19,"./toObject":46}],22:[function(require,module,exports){
  804. var baseIsMatch = require('./baseIsMatch'),
  805. getMatchData = require('./getMatchData'),
  806. toObject = require('./toObject');
  807. /**
  808. * The base implementation of `_.matches` which does not clone `source`.
  809. *
  810. * @private
  811. * @param {Object} source The object of property values to match.
  812. * @returns {Function} Returns the new function.
  813. */
  814. function baseMatches(source) {
  815. var matchData = getMatchData(source);
  816. if (matchData.length == 1 && matchData[0][2]) {
  817. var key = matchData[0][0],
  818. value = matchData[0][1];
  819. return function(object) {
  820. if (object == null) {
  821. return false;
  822. }
  823. return object[key] === value && (value !== undefined || (key in toObject(object)));
  824. };
  825. }
  826. return function(object) {
  827. return baseIsMatch(object, matchData);
  828. };
  829. }
  830. module.exports = baseMatches;
  831. },{"./baseIsMatch":21,"./getMatchData":36,"./toObject":46}],23:[function(require,module,exports){
  832. var baseGet = require('./baseGet'),
  833. baseIsEqual = require('./baseIsEqual'),
  834. baseSlice = require('./baseSlice'),
  835. isArray = require('../lang/isArray'),
  836. isKey = require('./isKey'),
  837. isStrictComparable = require('./isStrictComparable'),
  838. last = require('../array/last'),
  839. toObject = require('./toObject'),
  840. toPath = require('./toPath');
  841. /**
  842. * The base implementation of `_.matchesProperty` which does not clone `srcValue`.
  843. *
  844. * @private
  845. * @param {string} path The path of the property to get.
  846. * @param {*} srcValue The value to compare.
  847. * @returns {Function} Returns the new function.
  848. */
  849. function baseMatchesProperty(path, srcValue) {
  850. var isArr = isArray(path),
  851. isCommon = isKey(path) && isStrictComparable(srcValue),
  852. pathKey = (path + '');
  853. path = toPath(path);
  854. return function(object) {
  855. if (object == null) {
  856. return false;
  857. }
  858. var key = pathKey;
  859. object = toObject(object);
  860. if ((isArr || !isCommon) && !(key in object)) {
  861. object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  862. if (object == null) {
  863. return false;
  864. }
  865. key = last(path);
  866. object = toObject(object);
  867. }
  868. return object[key] === srcValue
  869. ? (srcValue !== undefined || (key in object))
  870. : baseIsEqual(srcValue, object[key], undefined, true);
  871. };
  872. }
  873. module.exports = baseMatchesProperty;
  874. },{"../array/last":4,"../lang/isArray":49,"./baseGet":18,"./baseIsEqual":19,"./baseSlice":26,"./isKey":41,"./isStrictComparable":44,"./toObject":46,"./toPath":47}],24:[function(require,module,exports){
  875. /**
  876. * The base implementation of `_.property` without support for deep paths.
  877. *
  878. * @private
  879. * @param {string} key The key of the property to get.
  880. * @returns {Function} Returns the new function.
  881. */
  882. function baseProperty(key) {
  883. return function(object) {
  884. return object == null ? undefined : object[key];
  885. };
  886. }
  887. module.exports = baseProperty;
  888. },{}],25:[function(require,module,exports){
  889. var baseGet = require('./baseGet'),
  890. toPath = require('./toPath');
  891. /**
  892. * A specialized version of `baseProperty` which supports deep paths.
  893. *
  894. * @private
  895. * @param {Array|string} path The path of the property to get.
  896. * @returns {Function} Returns the new function.
  897. */
  898. function basePropertyDeep(path) {
  899. var pathKey = (path + '');
  900. path = toPath(path);
  901. return function(object) {
  902. return baseGet(object, path, pathKey);
  903. };
  904. }
  905. module.exports = basePropertyDeep;
  906. },{"./baseGet":18,"./toPath":47}],26:[function(require,module,exports){
  907. /**
  908. * The base implementation of `_.slice` without an iteratee call guard.
  909. *
  910. * @private
  911. * @param {Array} array The array to slice.
  912. * @param {number} [start=0] The start position.
  913. * @param {number} [end=array.length] The end position.
  914. * @returns {Array} Returns the slice of `array`.
  915. */
  916. function baseSlice(array, start, end) {
  917. var index = -1,
  918. length = array.length;
  919. start = start == null ? 0 : (+start || 0);
  920. if (start < 0) {
  921. start = -start > length ? 0 : (length + start);
  922. }
  923. end = (end === undefined || end > length) ? length : (+end || 0);
  924. if (end < 0) {
  925. end += length;
  926. }
  927. length = start > end ? 0 : ((end - start) >>> 0);
  928. start >>>= 0;
  929. var result = Array(length);
  930. while (++index < length) {
  931. result[index] = array[index + start];
  932. }
  933. return result;
  934. }
  935. module.exports = baseSlice;
  936. },{}],27:[function(require,module,exports){
  937. /**
  938. * Converts `value` to a string if it's not one. An empty string is returned
  939. * for `null` or `undefined` values.
  940. *
  941. * @private
  942. * @param {*} value The value to process.
  943. * @returns {string} Returns the string.
  944. */
  945. function baseToString(value) {
  946. return value == null ? '' : (value + '');
  947. }
  948. module.exports = baseToString;
  949. },{}],28:[function(require,module,exports){
  950. var identity = require('../utility/identity');
  951. /**
  952. * A specialized version of `baseCallback` which only supports `this` binding
  953. * and specifying the number of arguments to provide to `func`.
  954. *
  955. * @private
  956. * @param {Function} func The function to bind.
  957. * @param {*} thisArg The `this` binding of `func`.
  958. * @param {number} [argCount] The number of arguments to provide to `func`.
  959. * @returns {Function} Returns the callback.
  960. */
  961. function bindCallback(func, thisArg, argCount) {
  962. if (typeof func != 'function') {
  963. return identity;
  964. }
  965. if (thisArg === undefined) {
  966. return func;
  967. }
  968. switch (argCount) {
  969. case 1: return function(value) {
  970. return func.call(thisArg, value);
  971. };
  972. case 3: return function(value, index, collection) {
  973. return func.call(thisArg, value, index, collection);
  974. };
  975. case 4: return function(accumulator, value, index, collection) {
  976. return func.call(thisArg, accumulator, value, index, collection);
  977. };
  978. case 5: return function(value, other, key, object, source) {
  979. return func.call(thisArg, value, other, key, object, source);
  980. };
  981. }
  982. return function() {
  983. return func.apply(thisArg, arguments);
  984. };
  985. }
  986. module.exports = bindCallback;
  987. },{"../utility/identity":61}],29:[function(require,module,exports){
  988. var bindCallback = require('./bindCallback'),
  989. isIterateeCall = require('./isIterateeCall'),
  990. restParam = require('../function/restParam');
  991. /**
  992. * Creates a `_.assign`, `_.defaults`, or `_.merge` function.
  993. *
  994. * @private
  995. * @param {Function} assigner The function to assign values.
  996. * @returns {Function} Returns the new assigner function.
  997. */
  998. function createAssigner(assigner) {
  999. return restParam(function(object, sources) {
  1000. var index = -1,
  1001. length = object == null ? 0 : sources.length,
  1002. customizer = length > 2 ? sources[length - 2] : undefined,
  1003. guard = length > 2 ? sources[2] : undefined,
  1004. thisArg = length > 1 ? sources[length - 1] : undefined;
  1005. if (typeof customizer == 'function') {
  1006. customizer = bindCallback(customizer, thisArg, 5);
  1007. length -= 2;
  1008. } else {
  1009. customizer = typeof thisArg == 'function' ? thisArg : undefined;
  1010. length -= (customizer ? 1 : 0);
  1011. }
  1012. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  1013. customizer = length < 3 ? undefined : customizer;
  1014. length = 1;
  1015. }
  1016. while (++index < length) {
  1017. var source = sources[index];
  1018. if (source) {
  1019. assigner(object, source, customizer);
  1020. }
  1021. }
  1022. return object;
  1023. });
  1024. }
  1025. module.exports = createAssigner;
  1026. },{"../function/restParam":6,"./bindCallback":28,"./isIterateeCall":40}],30:[function(require,module,exports){
  1027. var getLength = require('./getLength'),
  1028. isLength = require('./isLength'),
  1029. toObject = require('./toObject');
  1030. /**
  1031. * Creates a `baseEach` or `baseEachRight` function.
  1032. *
  1033. * @private
  1034. * @param {Function} eachFunc The function to iterate over a collection.
  1035. * @param {boolean} [fromRight] Specify iterating from right to left.
  1036. * @returns {Function} Returns the new base function.
  1037. */
  1038. function createBaseEach(eachFunc, fromRight) {
  1039. return function(collection, iteratee) {
  1040. var length = collection ? getLength(collection) : 0;
  1041. if (!isLength(length)) {
  1042. return eachFunc(collection, iteratee);
  1043. }
  1044. var index = fromRight ? length : -1,
  1045. iterable = toObject(collection);
  1046. while ((fromRight ? index-- : ++index < length)) {
  1047. if (iteratee(iterable[index], index, iterable) === false) {
  1048. break;
  1049. }
  1050. }
  1051. return collection;
  1052. };
  1053. }
  1054. module.exports = createBaseEach;
  1055. },{"./getLength":35,"./isLength":42,"./toObject":46}],31:[function(require,module,exports){
  1056. var toObject = require('./toObject');
  1057. /**
  1058. * Creates a base function for `_.forIn` or `_.forInRight`.
  1059. *
  1060. * @private
  1061. * @param {boolean} [fromRight] Specify iterating from right to left.
  1062. * @returns {Function} Returns the new base function.
  1063. */
  1064. function createBaseFor(fromRight) {
  1065. return function(object, iteratee, keysFunc) {
  1066. var iterable = toObject(object),
  1067. props = keysFunc(object),
  1068. length = props.length,
  1069. index = fromRight ? length : -1;
  1070. while ((fromRight ? index-- : ++index < length)) {
  1071. var key = props[index];
  1072. if (iteratee(iterable[key], key, iterable) === false) {
  1073. break;
  1074. }
  1075. }
  1076. return object;
  1077. };
  1078. }
  1079. module.exports = createBaseFor;
  1080. },{"./toObject":46}],32:[function(require,module,exports){
  1081. var arraySome = require('./arraySome');
  1082. /**
  1083. * A specialized version of `baseIsEqualDeep` for arrays with support for
  1084. * partial deep comparisons.
  1085. *
  1086. * @private
  1087. * @param {Array} array The array to compare.
  1088. * @param {Array} other The other array to compare.
  1089. * @param {Function} equalFunc The function to determine equivalents of values.
  1090. * @param {Function} [customizer] The function to customize comparing arrays.
  1091. * @param {boolean} [isLoose] Specify performing partial comparisons.
  1092. * @param {Array} [stackA] Tracks traversed `value` objects.
  1093. * @param {Array} [stackB] Tracks traversed `other` objects.
  1094. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  1095. */
  1096. function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
  1097. var index = -1,
  1098. arrLength = array.length,
  1099. othLength = other.length;
  1100. if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
  1101. return false;
  1102. }
  1103. // Ignore non-index properties.
  1104. while (++index < arrLength) {
  1105. var arrValue = array[index],
  1106. othValue = other[index],
  1107. result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined;
  1108. if (result !== undefined) {
  1109. if (result) {
  1110. continue;
  1111. }
  1112. return false;
  1113. }
  1114. // Recursively compare arrays (susceptible to call stack limits).
  1115. if (isLoose) {
  1116. if (!arraySome(other, function(othValue) {
  1117. return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
  1118. })) {
  1119. return false;
  1120. }
  1121. } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) {
  1122. return false;
  1123. }
  1124. }
  1125. return true;
  1126. }
  1127. module.exports = equalArrays;
  1128. },{"./arraySome":8}],33:[function(require,module,exports){
  1129. /** `Object#toString` result references. */
  1130. var boolTag = '[object Boolean]',
  1131. dateTag = '[object Date]',
  1132. errorTag = '[object Error]',
  1133. numberTag = '[object Number]',
  1134. regexpTag = '[object RegExp]',
  1135. stringTag = '[object String]';
  1136. /**
  1137. * A specialized version of `baseIsEqualDeep` for comparing objects of
  1138. * the same `toStringTag`.
  1139. *
  1140. * **Note:** This function only supports comparing values with tags of
  1141. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  1142. *
  1143. * @private
  1144. * @param {Object} object The object to compare.
  1145. * @param {Object} other The other object to compare.
  1146. * @param {string} tag The `toStringTag` of the objects to compare.
  1147. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  1148. */
  1149. function equalByTag(object, other, tag) {
  1150. switch (tag) {
  1151. case boolTag:
  1152. case dateTag:
  1153. // Coerce dates and booleans to numbers, dates to milliseconds and booleans
  1154. // to `1` or `0` treating invalid dates coerced to `NaN` as not equal.
  1155. return +object == +other;
  1156. case errorTag:
  1157. return object.name == other.name && object.message == other.message;
  1158. case numberTag:
  1159. // Treat `NaN` vs. `NaN` as equal.
  1160. return (object != +object)
  1161. ? other != +other
  1162. : object == +other;
  1163. case regexpTag:
  1164. case stringTag:
  1165. // Coerce regexes to strings and treat strings primitives and string
  1166. // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.
  1167. return object == (other + '');
  1168. }
  1169. return false;
  1170. }
  1171. module.exports = equalByTag;
  1172. },{}],34:[function(require,module,exports){
  1173. var keys = require('../object/keys');
  1174. /** Used for native method references. */
  1175. var objectProto = Object.prototype;
  1176. /** Used to check objects for own properties. */
  1177. var hasOwnProperty = objectProto.hasOwnProperty;
  1178. /**
  1179. * A specialized version of `baseIsEqualDeep` for objects with support for
  1180. * partial deep comparisons.
  1181. *
  1182. * @private
  1183. * @param {Object} object The object to compare.
  1184. * @param {Object} other The other object to compare.
  1185. * @param {Function} equalFunc The function to determine equivalents of values.
  1186. * @param {Function} [customizer] The function to customize comparing values.
  1187. * @param {boolean} [isLoose] Specify performing partial comparisons.
  1188. * @param {Array} [stackA] Tracks traversed `value` objects.
  1189. * @param {Array} [stackB] Tracks traversed `other` objects.
  1190. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  1191. */
  1192. function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  1193. var objProps = keys(object),
  1194. objLength = objProps.length,
  1195. othProps = keys(other),
  1196. othLength = othProps.length;
  1197. if (objLength != othLength && !isLoose) {
  1198. return false;
  1199. }
  1200. var index = objLength;
  1201. while (index--) {
  1202. var key = objProps[index];
  1203. if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) {
  1204. return false;
  1205. }
  1206. }
  1207. var skipCtor = isLoose;
  1208. while (++index < objLength) {
  1209. key = objProps[index];
  1210. var objValue = object[key],
  1211. othValue = other[key],
  1212. result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined;
  1213. // Recursively compare objects (susceptible to call stack limits).
  1214. if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) {
  1215. return false;
  1216. }
  1217. skipCtor || (skipCtor = key == 'constructor');
  1218. }
  1219. if (!skipCtor) {
  1220. var objCtor = object.constructor,
  1221. othCtor = other.constructor;
  1222. // Non `Object` object instances with different constructors are not equal.
  1223. if (objCtor != othCtor &&
  1224. ('constructor' in object && 'constructor' in other) &&
  1225. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  1226. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  1227. return false;
  1228. }
  1229. }
  1230. return true;
  1231. }
  1232. module.exports = equalObjects;
  1233. },{"../object/keys":58}],35:[function(require,module,exports){
  1234. var baseProperty = require('./baseProperty');
  1235. /**
  1236. * Gets the "length" property value of `object`.
  1237. *
  1238. * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
  1239. * that affects Safari on at least iOS 8.1-8.3 ARM64.
  1240. *
  1241. * @private
  1242. * @param {Object} object The object to query.
  1243. * @returns {*} Returns the "length" value.
  1244. */
  1245. var getLength = baseProperty('length');
  1246. module.exports = getLength;
  1247. },{"./baseProperty":24}],36:[function(require,module,exports){
  1248. var isStrictComparable = require('./isStrictComparable'),
  1249. pairs = require('../object/pairs');
  1250. /**
  1251. * Gets the propery names, values, and compare flags of `object`.
  1252. *
  1253. * @private
  1254. * @param {Object} object The object to query.
  1255. * @returns {Array} Returns the match data of `object`.
  1256. */
  1257. function getMatchData(object) {
  1258. var result = pairs(object),
  1259. length = result.length;
  1260. while (length--) {
  1261. result[length][2] = isStrictComparable(result[length][1]);
  1262. }
  1263. return result;
  1264. }
  1265. module.exports = getMatchData;
  1266. },{"../object/pairs":60,"./isStrictComparable":44}],37:[function(require,module,exports){
  1267. var isNative = require('../lang/isNative');
  1268. /**
  1269. * Gets the native function at `key` of `object`.
  1270. *
  1271. * @private
  1272. * @param {Object} object The object to query.
  1273. * @param {string} key The key of the method to get.
  1274. * @returns {*} Returns the function if it's native, else `undefined`.
  1275. */
  1276. function getNative(object, key) {
  1277. var value = object == null ? undefined : object[key];
  1278. return isNative(value) ? value : undefined;
  1279. }
  1280. module.exports = getNative;
  1281. },{"../lang/isNative":52}],38:[function(require,module,exports){
  1282. var getLength = require('./getLength'),
  1283. isLength = require('./isLength');
  1284. /**
  1285. * Checks if `value` is array-like.
  1286. *
  1287. * @private
  1288. * @param {*} value The value to check.
  1289. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  1290. */
  1291. function isArrayLike(value) {
  1292. return value != null && isLength(getLength(value));
  1293. }
  1294. module.exports = isArrayLike;
  1295. },{"./getLength":35,"./isLength":42}],39:[function(require,module,exports){
  1296. /** Used to detect unsigned integer values. */
  1297. var reIsUint = /^\d+$/;
  1298. /**
  1299. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  1300. * of an array-like value.
  1301. */
  1302. var MAX_SAFE_INTEGER = 9007199254740991;
  1303. /**
  1304. * Checks if `value` is a valid array-like index.
  1305. *
  1306. * @private
  1307. * @param {*} value The value to check.
  1308. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  1309. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  1310. */
  1311. function isIndex(value, length) {
  1312. value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
  1313. length = length == null ? MAX_SAFE_INTEGER : length;
  1314. return value > -1 && value % 1 == 0 && value < length;
  1315. }
  1316. module.exports = isIndex;
  1317. },{}],40:[function(require,module,exports){
  1318. var isArrayLike = require('./isArrayLike'),
  1319. isIndex = require('./isIndex'),
  1320. isObject = require('../lang/isObject');
  1321. /**
  1322. * Checks if the provided arguments are from an iteratee call.
  1323. *
  1324. * @private
  1325. * @param {*} value The potential iteratee value argument.
  1326. * @param {*} index The potential iteratee index or key argument.
  1327. * @param {*} object The potential iteratee object argument.
  1328. * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
  1329. */
  1330. function isIterateeCall(value, index, object) {
  1331. if (!isObject(object)) {
  1332. return false;
  1333. }
  1334. var type = typeof index;
  1335. if (type == 'number'
  1336. ? (isArrayLike(object) && isIndex(index, object.length))
  1337. : (type == 'string' && index in object)) {
  1338. var other = object[index];
  1339. return value === value ? (value === other) : (other !== other);
  1340. }
  1341. return false;
  1342. }
  1343. module.exports = isIterateeCall;
  1344. },{"../lang/isObject":53,"./isArrayLike":38,"./isIndex":39}],41:[function(require,module,exports){
  1345. var isArray = require('../lang/isArray'),
  1346. toObject = require('./toObject');
  1347. /** Used to match property names within property paths. */
  1348. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,
  1349. reIsPlainProp = /^\w*$/;
  1350. /**
  1351. * Checks if `value` is a property name and not a property path.
  1352. *
  1353. * @private
  1354. * @param {*} value The value to check.
  1355. * @param {Object} [object] The object to query keys on.
  1356. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  1357. */
  1358. function isKey(value, object) {
  1359. var type = typeof value;
  1360. if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') {
  1361. return true;
  1362. }
  1363. if (isArray(value)) {
  1364. return false;
  1365. }
  1366. var result = !reIsDeepProp.test(value);
  1367. return result || (object != null && value in toObject(object));
  1368. }
  1369. module.exports = isKey;
  1370. },{"../lang/isArray":49,"./toObject":46}],42:[function(require,module,exports){
  1371. /**
  1372. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  1373. * of an array-like value.
  1374. */
  1375. var MAX_SAFE_INTEGER = 9007199254740991;
  1376. /**
  1377. * Checks if `value` is a valid array-like length.
  1378. *
  1379. * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  1380. *
  1381. * @private
  1382. * @param {*} value The value to check.
  1383. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  1384. */
  1385. function isLength(value) {
  1386. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  1387. }
  1388. module.exports = isLength;
  1389. },{}],43:[function(require,module,exports){
  1390. /**
  1391. * Checks if `value` is object-like.
  1392. *
  1393. * @private
  1394. * @param {*} value The value to check.
  1395. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  1396. */
  1397. function isObjectLike(value) {
  1398. return !!value && typeof value == 'object';
  1399. }
  1400. module.exports = isObjectLike;
  1401. },{}],44:[function(require,module,exports){
  1402. var isObject = require('../lang/isObject');
  1403. /**
  1404. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  1405. *
  1406. * @private
  1407. * @param {*} value The value to check.
  1408. * @returns {boolean} Returns `true` if `value` if suitable for strict
  1409. * equality comparisons, else `false`.
  1410. */
  1411. function isStrictComparable(value) {
  1412. return value === value && !isObject(value);
  1413. }
  1414. module.exports = isStrictComparable;
  1415. },{"../lang/isObject":53}],45:[function(require,module,exports){
  1416. var isArguments = require('../lang/isArguments'),
  1417. isArray = require('../lang/isArray'),
  1418. isIndex = require('./isIndex'),
  1419. isLength = require('./isLength'),
  1420. keysIn = require('../object/keysIn');
  1421. /** Used for native method references. */
  1422. var objectProto = Object.prototype;
  1423. /** Used to check objects for own properties. */
  1424. var hasOwnProperty = objectProto.hasOwnProperty;
  1425. /**
  1426. * A fallback implementation of `Object.keys` which creates an array of the
  1427. * own enumerable property names of `object`.
  1428. *
  1429. * @private
  1430. * @param {Object} object The object to query.
  1431. * @returns {Array} Returns the array of property names.
  1432. */
  1433. function shimKeys(object) {
  1434. var props = keysIn(object),
  1435. propsLength = props.length,
  1436. length = propsLength && object.length;
  1437. var allowIndexes = !!length && isLength(length) &&
  1438. (isArray(object) || isArguments(object));
  1439. var index = -1,
  1440. result = [];
  1441. while (++index < propsLength) {
  1442. var key = props[index];
  1443. if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
  1444. result.push(key);
  1445. }
  1446. }
  1447. return result;
  1448. }
  1449. module.exports = shimKeys;
  1450. },{"../lang/isArguments":48,"../lang/isArray":49,"../object/keysIn":59,"./isIndex":39,"./isLength":42}],46:[function(require,module,exports){
  1451. var isObject = require('../lang/isObject');
  1452. /**
  1453. * Converts `value` to an object if it's not one.
  1454. *
  1455. * @private
  1456. * @param {*} value The value to process.
  1457. * @returns {Object} Returns the object.
  1458. */
  1459. function toObject(value) {
  1460. return isObject(value) ? value : Object(value);
  1461. }
  1462. module.exports = toObject;
  1463. },{"../lang/isObject":53}],47:[function(require,module,exports){
  1464. var baseToString = require('./baseToString'),
  1465. isArray = require('../lang/isArray');
  1466. /** Used to match property names within property paths. */
  1467. var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
  1468. /** Used to match backslashes in property paths. */
  1469. var reEscapeChar = /\\(\\)?/g;
  1470. /**
  1471. * Converts `value` to property path array if it's not one.
  1472. *
  1473. * @private
  1474. * @param {*} value The value to process.
  1475. * @returns {Array} Returns the property path array.
  1476. */
  1477. function toPath(value) {
  1478. if (isArray(value)) {
  1479. return value;
  1480. }
  1481. var result = [];
  1482. baseToString(value).replace(rePropName, function(match, number, quote, string) {
  1483. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  1484. });
  1485. return result;
  1486. }
  1487. module.exports = toPath;
  1488. },{"../lang/isArray":49,"./baseToString":27}],48:[function(require,module,exports){
  1489. var isArrayLike = require('../internal/isArrayLike'),
  1490. isObjectLike = require('../internal/isObjectLike');
  1491. /** Used for native method references. */
  1492. var objectProto = Object.prototype;
  1493. /** Used to check objects for own properties. */
  1494. var hasOwnProperty = objectProto.hasOwnProperty;
  1495. /** Native method references. */
  1496. var propertyIsEnumerable = objectProto.propertyIsEnumerable;
  1497. /**
  1498. * Checks if `value` is classified as an `arguments` object.
  1499. *
  1500. * @static
  1501. * @memberOf _
  1502. * @category Lang
  1503. * @param {*} value The value to check.
  1504. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  1505. * @example
  1506. *
  1507. * _.isArguments(function() { return arguments; }());
  1508. * // => true
  1509. *
  1510. * _.isArguments([1, 2, 3]);
  1511. * // => false
  1512. */
  1513. function isArguments(value) {
  1514. return isObjectLike(value) && isArrayLike(value) &&
  1515. hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
  1516. }
  1517. module.exports = isArguments;
  1518. },{"../internal/isArrayLike":38,"../internal/isObjectLike":43}],49:[function(require,module,exports){
  1519. var getNative = require('../internal/getNative'),
  1520. isLength = require('../internal/isLength'),
  1521. isObjectLike = require('../internal/isObjectLike');
  1522. /** `Object#toString` result references. */
  1523. var arrayTag = '[object Array]';
  1524. /** Used for native method references. */
  1525. var objectProto = Object.prototype;
  1526. /**
  1527. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1528. * of values.
  1529. */
  1530. var objToString = objectProto.toString;
  1531. /* Native method references for those with the same name as other `lodash` methods. */
  1532. var nativeIsArray = getNative(Array, 'isArray');
  1533. /**
  1534. * Checks if `value` is classified as an `Array` object.
  1535. *
  1536. * @static
  1537. * @memberOf _
  1538. * @category Lang
  1539. * @param {*} value The value to check.
  1540. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  1541. * @example
  1542. *
  1543. * _.isArray([1, 2, 3]);
  1544. * // => true
  1545. *
  1546. * _.isArray(function() { return arguments; }());
  1547. * // => false
  1548. */
  1549. var isArray = nativeIsArray || function(value) {
  1550. return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
  1551. };
  1552. module.exports = isArray;
  1553. },{"../internal/getNative":37,"../internal/isLength":42,"../internal/isObjectLike":43}],50:[function(require,module,exports){
  1554. var isArguments = require('./isArguments'),
  1555. isArray = require('./isArray'),
  1556. isArrayLike = require('../internal/isArrayLike'),
  1557. isFunction = require('./isFunction'),
  1558. isObjectLike = require('../internal/isObjectLike'),
  1559. isString = require('./isString'),
  1560. keys = require('../object/keys');
  1561. /**
  1562. * Checks if `value` is empty. A value is considered empty unless it's an
  1563. * `arguments` object, array, string, or jQuery-like collection with a length
  1564. * greater than `0` or an object with own enumerable properties.
  1565. *
  1566. * @static
  1567. * @memberOf _
  1568. * @category Lang
  1569. * @param {Array|Object|string} value The value to inspect.
  1570. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  1571. * @example
  1572. *
  1573. * _.isEmpty(null);
  1574. * // => true
  1575. *
  1576. * _.isEmpty(true);
  1577. * // => true
  1578. *
  1579. * _.isEmpty(1);
  1580. * // => true
  1581. *
  1582. * _.isEmpty([1, 2, 3]);
  1583. * // => false
  1584. *
  1585. * _.isEmpty({ 'a': 1 });
  1586. * // => false
  1587. */
  1588. function isEmpty(value) {
  1589. if (value == null) {
  1590. return true;
  1591. }
  1592. if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) ||
  1593. (isObjectLike(value) && isFunction(value.splice)))) {
  1594. return !value.length;
  1595. }
  1596. return !keys(value).length;
  1597. }
  1598. module.exports = isEmpty;
  1599. },{"../internal/isArrayLike":38,"../internal/isObjectLike":43,"../object/keys":58,"./isArguments":48,"./isArray":49,"./isFunction":51,"./isString":54}],51:[function(require,module,exports){
  1600. var isObject = require('./isObject');
  1601. /** `Object#toString` result references. */
  1602. var funcTag = '[object Function]';
  1603. /** Used for native method references. */
  1604. var objectProto = Object.prototype;
  1605. /**
  1606. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1607. * of values.
  1608. */
  1609. var objToString = objectProto.toString;
  1610. /**
  1611. * Checks if `value` is classified as a `Function` object.
  1612. *
  1613. * @static
  1614. * @memberOf _
  1615. * @category Lang
  1616. * @param {*} value The value to check.
  1617. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  1618. * @example
  1619. *
  1620. * _.isFunction(_);
  1621. * // => true
  1622. *
  1623. * _.isFunction(/abc/);
  1624. * // => false
  1625. */
  1626. function isFunction(value) {
  1627. // The use of `Object#toString` avoids issues with the `typeof` operator
  1628. // in older versions of Chrome and Safari which return 'function' for regexes
  1629. // and Safari 8 which returns 'object' for typed array constructors.
  1630. return isObject(value) && objToString.call(value) == funcTag;
  1631. }
  1632. module.exports = isFunction;
  1633. },{"./isObject":53}],52:[function(require,module,exports){
  1634. var isFunction = require('./isFunction'),
  1635. isObjectLike = require('../internal/isObjectLike');
  1636. /** Used to detect host constructors (Safari > 5). */
  1637. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  1638. /** Used for native method references. */
  1639. var objectProto = Object.prototype;
  1640. /** Used to resolve the decompiled source of functions. */
  1641. var fnToString = Function.prototype.toString;
  1642. /** Used to check objects for own properties. */
  1643. var hasOwnProperty = objectProto.hasOwnProperty;
  1644. /** Used to detect if a method is native. */
  1645. var reIsNative = RegExp('^' +
  1646. fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
  1647. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  1648. );
  1649. /**
  1650. * Checks if `value` is a native function.
  1651. *
  1652. * @static
  1653. * @memberOf _
  1654. * @category Lang
  1655. * @param {*} value The value to check.
  1656. * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
  1657. * @example
  1658. *
  1659. * _.isNative(Array.prototype.push);
  1660. * // => true
  1661. *
  1662. * _.isNative(_);
  1663. * // => false
  1664. */
  1665. function isNative(value) {
  1666. if (value == null) {
  1667. return false;
  1668. }
  1669. if (isFunction(value)) {
  1670. return reIsNative.test(fnToString.call(value));
  1671. }
  1672. return isObjectLike(value) && reIsHostCtor.test(value);
  1673. }
  1674. module.exports = isNative;
  1675. },{"../internal/isObjectLike":43,"./isFunction":51}],53:[function(require,module,exports){
  1676. /**
  1677. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  1678. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  1679. *
  1680. * @static
  1681. * @memberOf _
  1682. * @category Lang
  1683. * @param {*} value The value to check.
  1684. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  1685. * @example
  1686. *
  1687. * _.isObject({});
  1688. * // => true
  1689. *
  1690. * _.isObject([1, 2, 3]);
  1691. * // => true
  1692. *
  1693. * _.isObject(1);
  1694. * // => false
  1695. */
  1696. function isObject(value) {
  1697. // Avoid a V8 JIT bug in Chrome 19-20.
  1698. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  1699. var type = typeof value;
  1700. return !!value && (type == 'object' || type == 'function');
  1701. }
  1702. module.exports = isObject;
  1703. },{}],54:[function(require,module,exports){
  1704. var isObjectLike = require('../internal/isObjectLike');
  1705. /** `Object#toString` result references. */
  1706. var stringTag = '[object String]';
  1707. /** Used for native method references. */
  1708. var objectProto = Object.prototype;
  1709. /**
  1710. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1711. * of values.
  1712. */
  1713. var objToString = objectProto.toString;
  1714. /**
  1715. * Checks if `value` is classified as a `String` primitive or object.
  1716. *
  1717. * @static
  1718. * @memberOf _
  1719. * @category Lang
  1720. * @param {*} value The value to check.
  1721. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  1722. * @example
  1723. *
  1724. * _.isString('abc');
  1725. * // => true
  1726. *
  1727. * _.isString(1);
  1728. * // => false
  1729. */
  1730. function isString(value) {
  1731. return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
  1732. }
  1733. module.exports = isString;
  1734. },{"../internal/isObjectLike":43}],55:[function(require,module,exports){
  1735. var isLength = require('../internal/isLength'),
  1736. isObjectLike = require('../internal/isObjectLike');
  1737. /** `Object#toString` result references. */
  1738. var argsTag = '[object Arguments]',
  1739. arrayTag = '[object Array]',
  1740. boolTag = '[object Boolean]',
  1741. dateTag = '[object Date]',
  1742. errorTag = '[object Error]',
  1743. funcTag = '[object Function]',
  1744. mapTag = '[object Map]',
  1745. numberTag = '[object Number]',
  1746. objectTag = '[object Object]',
  1747. regexpTag = '[object RegExp]',
  1748. setTag = '[object Set]',
  1749. stringTag = '[object String]',
  1750. weakMapTag = '[object WeakMap]';
  1751. var arrayBufferTag = '[object ArrayBuffer]',
  1752. float32Tag = '[object Float32Array]',
  1753. float64Tag = '[object Float64Array]',
  1754. int8Tag = '[object Int8Array]',
  1755. int16Tag = '[object Int16Array]',
  1756. int32Tag = '[object Int32Array]',
  1757. uint8Tag = '[object Uint8Array]',
  1758. uint8ClampedTag = '[object Uint8ClampedArray]',
  1759. uint16Tag = '[object Uint16Array]',
  1760. uint32Tag = '[object Uint32Array]';
  1761. /** Used to identify `toStringTag` values of typed arrays. */
  1762. var typedArrayTags = {};
  1763. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  1764. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  1765. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  1766. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  1767. typedArrayTags[uint32Tag] = true;
  1768. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  1769. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  1770. typedArrayTags[dateTag] = typedArrayTags[errorTag] =
  1771. typedArrayTags[funcTag] = typedArrayTags[mapTag] =
  1772. typedArrayTags[numberTag] = typedArrayTags[objectTag] =
  1773. typedArrayTags[regexpTag] = typedArrayTags[setTag] =
  1774. typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  1775. /** Used for native method references. */
  1776. var objectProto = Object.prototype;
  1777. /**
  1778. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1779. * of values.
  1780. */
  1781. var objToString = objectProto.toString;
  1782. /**
  1783. * Checks if `value` is classified as a typed array.
  1784. *
  1785. * @static
  1786. * @memberOf _
  1787. * @category Lang
  1788. * @param {*} value The value to check.
  1789. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  1790. * @example
  1791. *
  1792. * _.isTypedArray(new Uint8Array);
  1793. * // => true
  1794. *
  1795. * _.isTypedArray([]);
  1796. * // => false
  1797. */
  1798. function isTypedArray(value) {
  1799. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
  1800. }
  1801. module.exports = isTypedArray;
  1802. },{"../internal/isLength":42,"../internal/isObjectLike":43}],56:[function(require,module,exports){
  1803. var assignWith = require('../internal/assignWith'),
  1804. baseAssign = require('../internal/baseAssign'),
  1805. createAssigner = require('../internal/createAssigner');
  1806. /**
  1807. * Assigns own enumerable properties of source object(s) to the destination
  1808. * object. Subsequent sources overwrite property assignments of previous sources.
  1809. * If `customizer` is provided it's invoked to produce the assigned values.
  1810. * The `customizer` is bound to `thisArg` and invoked with five arguments:
  1811. * (objectValue, sourceValue, key, object, source).
  1812. *
  1813. * **Note:** This method mutates `object` and is based on
  1814. * [`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign).
  1815. *
  1816. * @static
  1817. * @memberOf _
  1818. * @alias extend
  1819. * @category Object
  1820. * @param {Object} object The destination object.
  1821. * @param {...Object} [sources] The source objects.
  1822. * @param {Function} [customizer] The function to customize assigned values.
  1823. * @param {*} [thisArg] The `this` binding of `customizer`.
  1824. * @returns {Object} Returns `object`.
  1825. * @example
  1826. *
  1827. * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' });
  1828. * // => { 'user': 'fred', 'age': 40 }
  1829. *
  1830. * // using a customizer callback
  1831. * var defaults = _.partialRight(_.assign, function(value, other) {
  1832. * return _.isUndefined(value) ? other : value;
  1833. * });
  1834. *
  1835. * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
  1836. * // => { 'user': 'barney', 'age': 36 }
  1837. */
  1838. var assign = createAssigner(function(object, source, customizer) {
  1839. return customizer
  1840. ? assignWith(object, source, customizer)
  1841. : baseAssign(object, source);
  1842. });
  1843. module.exports = assign;
  1844. },{"../internal/assignWith":9,"../internal/baseAssign":10,"../internal/createAssigner":29}],57:[function(require,module,exports){
  1845. var baseAssign = require('../internal/baseAssign'),
  1846. baseCreate = require('../internal/baseCreate'),
  1847. isIterateeCall = require('../internal/isIterateeCall');
  1848. /**
  1849. * Creates an object that inherits from the given `prototype` object. If a
  1850. * `properties` object is provided its own enumerable properties are assigned
  1851. * to the created object.
  1852. *
  1853. * @static
  1854. * @memberOf _
  1855. * @category Object
  1856. * @param {Object} prototype The object to inherit from.
  1857. * @param {Object} [properties] The properties to assign to the object.
  1858. * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
  1859. * @returns {Object} Returns the new object.
  1860. * @example
  1861. *
  1862. * function Shape() {
  1863. * this.x = 0;
  1864. * this.y = 0;
  1865. * }
  1866. *
  1867. * function Circle() {
  1868. * Shape.call(this);
  1869. * }
  1870. *
  1871. * Circle.prototype = _.create(Shape.prototype, {
  1872. * 'constructor': Circle
  1873. * });
  1874. *
  1875. * var circle = new Circle;
  1876. * circle instanceof Circle;
  1877. * // => true
  1878. *
  1879. * circle instanceof Shape;
  1880. * // => true
  1881. */
  1882. function create(prototype, properties, guard) {
  1883. var result = baseCreate(prototype);
  1884. if (guard && isIterateeCall(prototype, properties, guard)) {
  1885. properties = undefined;
  1886. }
  1887. return properties ? baseAssign(result, properties) : result;
  1888. }
  1889. module.exports = create;
  1890. },{"../internal/baseAssign":10,"../internal/baseCreate":13,"../internal/isIterateeCall":40}],58:[function(require,module,exports){
  1891. var getNative = require('../internal/getNative'),
  1892. isArrayLike = require('../internal/isArrayLike'),
  1893. isObject = require('../lang/isObject'),
  1894. shimKeys = require('../internal/shimKeys');
  1895. /* Native method references for those with the same name as other `lodash` methods. */
  1896. var nativeKeys = getNative(Object, 'keys');
  1897. /**
  1898. * Creates an array of the own enumerable property names of `object`.
  1899. *
  1900. * **Note:** Non-object values are coerced to objects. See the
  1901. * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
  1902. * for more details.
  1903. *
  1904. * @static
  1905. * @memberOf _
  1906. * @category Object
  1907. * @param {Object} object The object to query.
  1908. * @returns {Array} Returns the array of property names.
  1909. * @example
  1910. *
  1911. * function Foo() {
  1912. * this.a = 1;
  1913. * this.b = 2;
  1914. * }
  1915. *
  1916. * Foo.prototype.c = 3;
  1917. *
  1918. * _.keys(new Foo);
  1919. * // => ['a', 'b'] (iteration order is not guaranteed)
  1920. *
  1921. * _.keys('hi');
  1922. * // => ['0', '1']
  1923. */
  1924. var keys = !nativeKeys ? shimKeys : function(object) {
  1925. var Ctor = object == null ? undefined : object.constructor;
  1926. if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
  1927. (typeof object != 'function' && isArrayLike(object))) {
  1928. return shimKeys(object);
  1929. }
  1930. return isObject(object) ? nativeKeys(object) : [];
  1931. };
  1932. module.exports = keys;
  1933. },{"../internal/getNative":37,"../internal/isArrayLike":38,"../internal/shimKeys":45,"../lang/isObject":53}],59:[function(require,module,exports){
  1934. var isArguments = require('../lang/isArguments'),
  1935. isArray = require('../lang/isArray'),
  1936. isIndex = require('../internal/isIndex'),
  1937. isLength = require('../internal/isLength'),
  1938. isObject = require('../lang/isObject');
  1939. /** Used for native method references. */
  1940. var objectProto = Object.prototype;
  1941. /** Used to check objects for own properties. */
  1942. var hasOwnProperty = objectProto.hasOwnProperty;
  1943. /**
  1944. * Creates an array of the own and inherited enumerable property names of `object`.
  1945. *
  1946. * **Note:** Non-object values are coerced to objects.
  1947. *
  1948. * @static
  1949. * @memberOf _
  1950. * @category Object
  1951. * @param {Object} object The object to query.
  1952. * @returns {Array} Returns the array of property names.
  1953. * @example
  1954. *
  1955. * function Foo() {
  1956. * this.a = 1;
  1957. * this.b = 2;
  1958. * }
  1959. *
  1960. * Foo.prototype.c = 3;
  1961. *
  1962. * _.keysIn(new Foo);
  1963. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  1964. */
  1965. function keysIn(object) {
  1966. if (object == null) {
  1967. return [];
  1968. }
  1969. if (!isObject(object)) {
  1970. object = Object(object);
  1971. }
  1972. var length = object.length;
  1973. length = (length && isLength(length) &&
  1974. (isArray(object) || isArguments(object)) && length) || 0;
  1975. var Ctor = object.constructor,
  1976. index = -1,
  1977. isProto = typeof Ctor == 'function' && Ctor.prototype === object,
  1978. result = Array(length),
  1979. skipIndexes = length > 0;
  1980. while (++index < length) {
  1981. result[index] = (index + '');
  1982. }
  1983. for (var key in object) {
  1984. if (!(skipIndexes && isIndex(key, length)) &&
  1985. !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  1986. result.push(key);
  1987. }
  1988. }
  1989. return result;
  1990. }
  1991. module.exports = keysIn;
  1992. },{"../internal/isIndex":39,"../internal/isLength":42,"../lang/isArguments":48,"../lang/isArray":49,"../lang/isObject":53}],60:[function(require,module,exports){
  1993. var keys = require('./keys'),
  1994. toObject = require('../internal/toObject');
  1995. /**
  1996. * Creates a two dimensional array of the key-value pairs for `object`,
  1997. * e.g. `[[key1, value1], [key2, value2]]`.
  1998. *
  1999. * @static
  2000. * @memberOf _
  2001. * @category Object
  2002. * @param {Object} object The object to query.
  2003. * @returns {Array} Returns the new array of key-value pairs.
  2004. * @example
  2005. *
  2006. * _.pairs({ 'barney': 36, 'fred': 40 });
  2007. * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed)
  2008. */
  2009. function pairs(object) {
  2010. object = toObject(object);
  2011. var index = -1,
  2012. props = keys(object),
  2013. length = props.length,
  2014. result = Array(length);
  2015. while (++index < length) {
  2016. var key = props[index];
  2017. result[index] = [key, object[key]];
  2018. }
  2019. return result;
  2020. }
  2021. module.exports = pairs;
  2022. },{"../internal/toObject":46,"./keys":58}],61:[function(require,module,exports){
  2023. /**
  2024. * This method returns the first argument provided to it.
  2025. *
  2026. * @static
  2027. * @memberOf _
  2028. * @category Utility
  2029. * @param {*} value Any value.
  2030. * @returns {*} Returns `value`.
  2031. * @example
  2032. *
  2033. * var object = { 'user': 'fred' };
  2034. *
  2035. * _.identity(object) === object;
  2036. * // => true
  2037. */
  2038. function identity(value) {
  2039. return value;
  2040. }
  2041. module.exports = identity;
  2042. },{}],62:[function(require,module,exports){
  2043. var baseProperty = require('../internal/baseProperty'),
  2044. basePropertyDeep = require('../internal/basePropertyDeep'),
  2045. isKey = require('../internal/isKey');
  2046. /**
  2047. * Creates a function that returns the property value at `path` on a
  2048. * given object.
  2049. *
  2050. * @static
  2051. * @memberOf _
  2052. * @category Utility
  2053. * @param {Array|string} path The path of the property to get.
  2054. * @returns {Function} Returns the new function.
  2055. * @example
  2056. *
  2057. * var objects = [
  2058. * { 'a': { 'b': { 'c': 2 } } },
  2059. * { 'a': { 'b': { 'c': 1 } } }
  2060. * ];
  2061. *
  2062. * _.map(objects, _.property('a.b.c'));
  2063. * // => [2, 1]
  2064. *
  2065. * _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c');
  2066. * // => [1, 2]
  2067. */
  2068. function property(path) {
  2069. return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
  2070. }
  2071. module.exports = property;
  2072. },{"../internal/baseProperty":24,"../internal/basePropertyDeep":25,"../internal/isKey":41}],63:[function(require,module,exports){
  2073. // Generated by CoffeeScript 1.9.1
  2074. (function() {
  2075. var XMLAttribute, create;
  2076. create = require('lodash/object/create');
  2077. module.exports = XMLAttribute = (function() {
  2078. function XMLAttribute(parent, name, value) {
  2079. this.stringify = parent.stringify;
  2080. if (name == null) {
  2081. throw new Error("Missing attribute name of element " + parent.name);
  2082. }
  2083. if (value == null) {
  2084. throw new Error("Missing attribute value for attribute " + name + " of element " + parent.name);
  2085. }
  2086. this.name = this.stringify.attName(name);
  2087. this.value = this.stringify.attValue(value);
  2088. }
  2089. XMLAttribute.prototype.clone = function() {
  2090. return create(XMLAttribute.prototype, this);
  2091. };
  2092. XMLAttribute.prototype.toString = function(options, level) {
  2093. return ' ' + this.name + '="' + this.value + '"';
  2094. };
  2095. return XMLAttribute;
  2096. })();
  2097. }).call(this);
  2098. },{"lodash/object/create":57}],64:[function(require,module,exports){
  2099. // Generated by CoffeeScript 1.9.1
  2100. (function() {
  2101. var XMLBuilder, XMLDeclaration, XMLDocType, XMLElement, XMLStringifier;
  2102. XMLStringifier = require('./XMLStringifier');
  2103. XMLDeclaration = require('./XMLDeclaration');
  2104. XMLDocType = require('./XMLDocType');
  2105. XMLElement = require('./XMLElement');
  2106. module.exports = XMLBuilder = (function() {
  2107. function XMLBuilder(name, options) {
  2108. var root, temp;
  2109. if (name == null) {
  2110. throw new Error("Root element needs a name");
  2111. }
  2112. if (options == null) {
  2113. options = {};
  2114. }
  2115. this.options = options;
  2116. this.stringify = new XMLStringifier(options);
  2117. temp = new XMLElement(this, 'doc');
  2118. root = temp.element(name);
  2119. root.isRoot = true;
  2120. root.documentObject = this;
  2121. this.rootObject = root;
  2122. if (!options.headless) {
  2123. root.declaration(options);
  2124. if ((options.pubID != null) || (options.sysID != null)) {
  2125. root.doctype(options);
  2126. }
  2127. }
  2128. }
  2129. XMLBuilder.prototype.root = function() {
  2130. return this.rootObject;
  2131. };
  2132. XMLBuilder.prototype.end = function(options) {
  2133. return this.toString(options);
  2134. };
  2135. XMLBuilder.prototype.toString = function(options) {
  2136. var indent, newline, offset, pretty, r, ref, ref1, ref2;
  2137. pretty = (options != null ? options.pretty : void 0) || false;
  2138. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  2139. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  2140. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  2141. r = '';
  2142. if (this.xmldec != null) {
  2143. r += this.xmldec.toString(options);
  2144. }
  2145. if (this.doctype != null) {
  2146. r += this.doctype.toString(options);
  2147. }
  2148. r += this.rootObject.toString(options);
  2149. if (pretty && r.slice(-newline.length) === newline) {
  2150. r = r.slice(0, -newline.length);
  2151. }
  2152. return r;
  2153. };
  2154. return XMLBuilder;
  2155. })();
  2156. }).call(this);
  2157. },{"./XMLDeclaration":71,"./XMLDocType":72,"./XMLElement":73,"./XMLStringifier":77}],65:[function(require,module,exports){
  2158. // Generated by CoffeeScript 1.9.1
  2159. (function() {
  2160. var XMLCData, XMLNode, create,
  2161. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  2162. hasProp = {}.hasOwnProperty;
  2163. create = require('lodash/object/create');
  2164. XMLNode = require('./XMLNode');
  2165. module.exports = XMLCData = (function(superClass) {
  2166. extend(XMLCData, superClass);
  2167. function XMLCData(parent, text) {
  2168. XMLCData.__super__.constructor.call(this, parent);
  2169. if (text == null) {
  2170. throw new Error("Missing CDATA text");
  2171. }
  2172. this.text = this.stringify.cdata(text);
  2173. }
  2174. XMLCData.prototype.clone = function() {
  2175. return create(XMLCData.prototype, this);
  2176. };
  2177. XMLCData.prototype.toString = function(options, level) {
  2178. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  2179. pretty = (options != null ? options.pretty : void 0) || false;
  2180. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  2181. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  2182. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  2183. level || (level = 0);
  2184. space = new Array(level + offset + 1).join(indent);
  2185. r = '';
  2186. if (pretty) {
  2187. r += space;
  2188. }
  2189. r += '<![CDATA[' + this.text + ']]>';
  2190. if (pretty) {
  2191. r += newline;
  2192. }
  2193. return r;
  2194. };
  2195. return XMLCData;
  2196. })(XMLNode);
  2197. }).call(this);
  2198. },{"./XMLNode":74,"lodash/object/create":57}],66:[function(require,module,exports){
  2199. // Generated by CoffeeScript 1.9.1
  2200. (function() {
  2201. var XMLComment, XMLNode, create,
  2202. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  2203. hasProp = {}.hasOwnProperty;
  2204. create = require('lodash/object/create');
  2205. XMLNode = require('./XMLNode');
  2206. module.exports = XMLComment = (function(superClass) {
  2207. extend(XMLComment, superClass);
  2208. function XMLComment(parent, text) {
  2209. XMLComment.__super__.constructor.call(this, parent);
  2210. if (text == null) {
  2211. throw new Error("Missing comment text");
  2212. }
  2213. this.text = this.stringify.comment(text);
  2214. }
  2215. XMLComment.prototype.clone = function() {
  2216. return create(XMLComment.prototype, this);
  2217. };
  2218. XMLComment.prototype.toString = function(options, level) {
  2219. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  2220. pretty = (options != null ? options.pretty : void 0) || false;
  2221. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  2222. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  2223. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  2224. level || (level = 0);
  2225. space = new Array(level + offset + 1).join(indent);
  2226. r = '';
  2227. if (pretty) {
  2228. r += space;
  2229. }
  2230. r += '<!-- ' + this.text + ' -->';
  2231. if (pretty) {
  2232. r += newline;
  2233. }
  2234. return r;
  2235. };
  2236. return XMLComment;
  2237. })(XMLNode);
  2238. }).call(this);
  2239. },{"./XMLNode":74,"lodash/object/create":57}],67:[function(require,module,exports){
  2240. // Generated by CoffeeScript 1.9.1
  2241. (function() {
  2242. var XMLDTDAttList, create;
  2243. create = require('lodash/object/create');
  2244. module.exports = XMLDTDAttList = (function() {
  2245. function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  2246. this.stringify = parent.stringify;
  2247. if (elementName == null) {
  2248. throw new Error("Missing DTD element name");
  2249. }
  2250. if (attributeName == null) {
  2251. throw new Error("Missing DTD attribute name");
  2252. }
  2253. if (!attributeType) {
  2254. throw new Error("Missing DTD attribute type");
  2255. }
  2256. if (!defaultValueType) {
  2257. throw new Error("Missing DTD attribute default");
  2258. }
  2259. if (defaultValueType.indexOf('#') !== 0) {
  2260. defaultValueType = '#' + defaultValueType;
  2261. }
  2262. if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
  2263. throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT");
  2264. }
  2265. if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
  2266. throw new Error("Default value only applies to #FIXED or #DEFAULT");
  2267. }
  2268. this.elementName = this.stringify.eleName(elementName);
  2269. this.attributeName = this.stringify.attName(attributeName);
  2270. this.attributeType = this.stringify.dtdAttType(attributeType);
  2271. this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
  2272. this.defaultValueType = defaultValueType;
  2273. }
  2274. XMLDTDAttList.prototype.toString = function(options, level) {
  2275. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  2276. pretty = (options != null ? options.pretty : void 0) || false;
  2277. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  2278. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  2279. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  2280. level || (level = 0);
  2281. space = new Array(level + offset + 1).join(indent);
  2282. r = '';
  2283. if (pretty) {
  2284. r += space;
  2285. }
  2286. r += '<!ATTLIST ' + this.elementName + ' ' + this.attributeName + ' ' + this.attributeType;
  2287. if (this.defaultValueType !== '#DEFAULT') {
  2288. r += ' ' + this.defaultValueType;
  2289. }
  2290. if (this.defaultValue) {
  2291. r += ' "' + this.defaultValue + '"';
  2292. }
  2293. r += '>';
  2294. if (pretty) {
  2295. r += newline;
  2296. }
  2297. return r;
  2298. };
  2299. return XMLDTDAttList;
  2300. })();
  2301. }).call(this);
  2302. },{"lodash/object/create":57}],68:[function(require,module,exports){
  2303. // Generated by CoffeeScript 1.9.1
  2304. (function() {
  2305. var XMLDTDElement, create;
  2306. create = require('lodash/object/create');
  2307. module.exports = XMLDTDElement = (function() {
  2308. function XMLDTDElement(parent, name, value) {
  2309. this.stringify = parent.stringify;
  2310. if (name == null) {
  2311. throw new Error("Missing DTD element name");
  2312. }
  2313. if (!value) {
  2314. value = '(#PCDATA)';
  2315. }
  2316. if (Array.isArray(value)) {
  2317. value = '(' + value.join(',') + ')';
  2318. }
  2319. this.name = this.stringify.eleName(name);
  2320. this.value = this.stringify.dtdElementValue(value);
  2321. }
  2322. XMLDTDElement.prototype.toString = function(options, level) {
  2323. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  2324. pretty = (options != null ? options.pretty : void 0) || false;
  2325. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  2326. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  2327. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  2328. level || (level = 0);
  2329. space = new Array(level + offset + 1).join(indent);
  2330. r = '';
  2331. if (pretty) {
  2332. r += space;
  2333. }
  2334. r += '<!ELEMENT ' + this.name + ' ' + this.value + '>';
  2335. if (pretty) {
  2336. r += newline;
  2337. }
  2338. return r;
  2339. };
  2340. return XMLDTDElement;
  2341. })();
  2342. }).call(this);
  2343. },{"lodash/object/create":57}],69:[function(require,module,exports){
  2344. // Generated by CoffeeScript 1.9.1
  2345. (function() {
  2346. var XMLDTDEntity, create, isObject;
  2347. create = require('lodash/object/create');
  2348. isObject = require('lodash/lang/isObject');
  2349. module.exports = XMLDTDEntity = (function() {
  2350. function XMLDTDEntity(parent, pe, name, value) {
  2351. this.stringify = parent.stringify;
  2352. if (name == null) {
  2353. throw new Error("Missing entity name");
  2354. }
  2355. if (value == null) {
  2356. throw new Error("Missing entity value");
  2357. }
  2358. this.pe = !!pe;
  2359. this.name = this.stringify.eleName(name);
  2360. if (!isObject(value)) {
  2361. this.value = this.stringify.dtdEntityValue(value);
  2362. } else {
  2363. if (!value.pubID && !value.sysID) {
  2364. throw new Error("Public and/or system identifiers are required for an external entity");
  2365. }
  2366. if (value.pubID && !value.sysID) {
  2367. throw new Error("System identifier is required for a public external entity");
  2368. }
  2369. if (value.pubID != null) {
  2370. this.pubID = this.stringify.dtdPubID(value.pubID);
  2371. }
  2372. if (value.sysID != null) {
  2373. this.sysID = this.stringify.dtdSysID(value.sysID);
  2374. }
  2375. if (value.nData != null) {
  2376. this.nData = this.stringify.dtdNData(value.nData);
  2377. }
  2378. if (this.pe && this.nData) {
  2379. throw new Error("Notation declaration is not allowed in a parameter entity");
  2380. }
  2381. }
  2382. }
  2383. XMLDTDEntity.prototype.toString = function(options, level) {
  2384. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  2385. pretty = (options != null ? options.pretty : void 0) || false;
  2386. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  2387. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  2388. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  2389. level || (level = 0);
  2390. space = new Array(level + offset + 1).join(indent);
  2391. r = '';
  2392. if (pretty) {
  2393. r += space;
  2394. }
  2395. r += '<!ENTITY';
  2396. if (this.pe) {
  2397. r += ' %';
  2398. }
  2399. r += ' ' + this.name;
  2400. if (this.value) {
  2401. r += ' "' + this.value + '"';
  2402. } else {
  2403. if (this.pubID && this.sysID) {
  2404. r += ' PUBLIC "' + this.pubID + '" "' + this.sysID + '"';
  2405. } else if (this.sysID) {
  2406. r += ' SYSTEM "' + this.sysID + '"';
  2407. }
  2408. if (this.nData) {
  2409. r += ' NDATA ' + this.nData;
  2410. }
  2411. }
  2412. r += '>';
  2413. if (pretty) {
  2414. r += newline;
  2415. }
  2416. return r;
  2417. };
  2418. return XMLDTDEntity;
  2419. })();
  2420. }).call(this);
  2421. },{"lodash/lang/isObject":53,"lodash/object/create":57}],70:[function(require,module,exports){
  2422. // Generated by CoffeeScript 1.9.1
  2423. (function() {
  2424. var XMLDTDNotation, create;
  2425. create = require('lodash/object/create');
  2426. module.exports = XMLDTDNotation = (function() {
  2427. function XMLDTDNotation(parent, name, value) {
  2428. this.stringify = parent.stringify;
  2429. if (name == null) {
  2430. throw new Error("Missing notation name");
  2431. }
  2432. if (!value.pubID && !value.sysID) {
  2433. throw new Error("Public or system identifiers are required for an external entity");
  2434. }
  2435. this.name = this.stringify.eleName(name);
  2436. if (value.pubID != null) {
  2437. this.pubID = this.stringify.dtdPubID(value.pubID);
  2438. }
  2439. if (value.sysID != null) {
  2440. this.sysID = this.stringify.dtdSysID(value.sysID);
  2441. }
  2442. }
  2443. XMLDTDNotation.prototype.toString = function(options, level) {
  2444. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  2445. pretty = (options != null ? options.pretty : void 0) || false;
  2446. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  2447. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  2448. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  2449. level || (level = 0);
  2450. space = new Array(level + offset + 1).join(indent);
  2451. r = '';
  2452. if (pretty) {
  2453. r += space;
  2454. }
  2455. r += '<!NOTATION ' + this.name;
  2456. if (this.pubID && this.sysID) {
  2457. r += ' PUBLIC "' + this.pubID + '" "' + this.sysID + '"';
  2458. } else if (this.pubID) {
  2459. r += ' PUBLIC "' + this.pubID + '"';
  2460. } else if (this.sysID) {
  2461. r += ' SYSTEM "' + this.sysID + '"';
  2462. }
  2463. r += '>';
  2464. if (pretty) {
  2465. r += newline;
  2466. }
  2467. return r;
  2468. };
  2469. return XMLDTDNotation;
  2470. })();
  2471. }).call(this);
  2472. },{"lodash/object/create":57}],71:[function(require,module,exports){
  2473. // Generated by CoffeeScript 1.9.1
  2474. (function() {
  2475. var XMLDeclaration, XMLNode, create, isObject,
  2476. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  2477. hasProp = {}.hasOwnProperty;
  2478. create = require('lodash/object/create');
  2479. isObject = require('lodash/lang/isObject');
  2480. XMLNode = require('./XMLNode');
  2481. module.exports = XMLDeclaration = (function(superClass) {
  2482. extend(XMLDeclaration, superClass);
  2483. function XMLDeclaration(parent, version, encoding, standalone) {
  2484. var ref;
  2485. XMLDeclaration.__super__.constructor.call(this, parent);
  2486. if (isObject(version)) {
  2487. ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
  2488. }
  2489. if (!version) {
  2490. version = '1.0';
  2491. }
  2492. this.version = this.stringify.xmlVersion(version);
  2493. if (encoding != null) {
  2494. this.encoding = this.stringify.xmlEncoding(encoding);
  2495. }
  2496. if (standalone != null) {
  2497. this.standalone = this.stringify.xmlStandalone(standalone);
  2498. }
  2499. }
  2500. XMLDeclaration.prototype.toString = function(options, level) {
  2501. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  2502. pretty = (options != null ? options.pretty : void 0) || false;
  2503. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  2504. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  2505. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  2506. level || (level = 0);
  2507. space = new Array(level + offset + 1).join(indent);
  2508. r = '';
  2509. if (pretty) {
  2510. r += space;
  2511. }
  2512. r += '<?xml';
  2513. r += ' version="' + this.version + '"';
  2514. if (this.encoding != null) {
  2515. r += ' encoding="' + this.encoding + '"';
  2516. }
  2517. if (this.standalone != null) {
  2518. r += ' standalone="' + this.standalone + '"';
  2519. }
  2520. r += '?>';
  2521. if (pretty) {
  2522. r += newline;
  2523. }
  2524. return r;
  2525. };
  2526. return XMLDeclaration;
  2527. })(XMLNode);
  2528. }).call(this);
  2529. },{"./XMLNode":74,"lodash/lang/isObject":53,"lodash/object/create":57}],72:[function(require,module,exports){
  2530. // Generated by CoffeeScript 1.9.1
  2531. (function() {
  2532. var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLProcessingInstruction, create, isObject;
  2533. create = require('lodash/object/create');
  2534. isObject = require('lodash/lang/isObject');
  2535. XMLCData = require('./XMLCData');
  2536. XMLComment = require('./XMLComment');
  2537. XMLDTDAttList = require('./XMLDTDAttList');
  2538. XMLDTDEntity = require('./XMLDTDEntity');
  2539. XMLDTDElement = require('./XMLDTDElement');
  2540. XMLDTDNotation = require('./XMLDTDNotation');
  2541. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  2542. module.exports = XMLDocType = (function() {
  2543. function XMLDocType(parent, pubID, sysID) {
  2544. var ref, ref1;
  2545. this.documentObject = parent;
  2546. this.stringify = this.documentObject.stringify;
  2547. this.children = [];
  2548. if (isObject(pubID)) {
  2549. ref = pubID, pubID = ref.pubID, sysID = ref.sysID;
  2550. }
  2551. if (sysID == null) {
  2552. ref1 = [pubID, sysID], sysID = ref1[0], pubID = ref1[1];
  2553. }
  2554. if (pubID != null) {
  2555. this.pubID = this.stringify.dtdPubID(pubID);
  2556. }
  2557. if (sysID != null) {
  2558. this.sysID = this.stringify.dtdSysID(sysID);
  2559. }
  2560. }
  2561. XMLDocType.prototype.element = function(name, value) {
  2562. var child;
  2563. child = new XMLDTDElement(this, name, value);
  2564. this.children.push(child);
  2565. return this;
  2566. };
  2567. XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  2568. var child;
  2569. child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
  2570. this.children.push(child);
  2571. return this;
  2572. };
  2573. XMLDocType.prototype.entity = function(name, value) {
  2574. var child;
  2575. child = new XMLDTDEntity(this, false, name, value);
  2576. this.children.push(child);
  2577. return this;
  2578. };
  2579. XMLDocType.prototype.pEntity = function(name, value) {
  2580. var child;
  2581. child = new XMLDTDEntity(this, true, name, value);
  2582. this.children.push(child);
  2583. return this;
  2584. };
  2585. XMLDocType.prototype.notation = function(name, value) {
  2586. var child;
  2587. child = new XMLDTDNotation(this, name, value);
  2588. this.children.push(child);
  2589. return this;
  2590. };
  2591. XMLDocType.prototype.cdata = function(value) {
  2592. var child;
  2593. child = new XMLCData(this, value);
  2594. this.children.push(child);
  2595. return this;
  2596. };
  2597. XMLDocType.prototype.comment = function(value) {
  2598. var child;
  2599. child = new XMLComment(this, value);
  2600. this.children.push(child);
  2601. return this;
  2602. };
  2603. XMLDocType.prototype.instruction = function(target, value) {
  2604. var child;
  2605. child = new XMLProcessingInstruction(this, target, value);
  2606. this.children.push(child);
  2607. return this;
  2608. };
  2609. XMLDocType.prototype.root = function() {
  2610. return this.documentObject.root();
  2611. };
  2612. XMLDocType.prototype.document = function() {
  2613. return this.documentObject;
  2614. };
  2615. XMLDocType.prototype.toString = function(options, level) {
  2616. var child, i, indent, len, newline, offset, pretty, r, ref, ref1, ref2, ref3, space;
  2617. pretty = (options != null ? options.pretty : void 0) || false;
  2618. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  2619. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  2620. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  2621. level || (level = 0);
  2622. space = new Array(level + offset + 1).join(indent);
  2623. r = '';
  2624. if (pretty) {
  2625. r += space;
  2626. }
  2627. r += '<!DOCTYPE ' + this.root().name;
  2628. if (this.pubID && this.sysID) {
  2629. r += ' PUBLIC "' + this.pubID + '" "' + this.sysID + '"';
  2630. } else if (this.sysID) {
  2631. r += ' SYSTEM "' + this.sysID + '"';
  2632. }
  2633. if (this.children.length > 0) {
  2634. r += ' [';
  2635. if (pretty) {
  2636. r += newline;
  2637. }
  2638. ref3 = this.children;
  2639. for (i = 0, len = ref3.length; i < len; i++) {
  2640. child = ref3[i];
  2641. r += child.toString(options, level + 1);
  2642. }
  2643. r += ']';
  2644. }
  2645. r += '>';
  2646. if (pretty) {
  2647. r += newline;
  2648. }
  2649. return r;
  2650. };
  2651. XMLDocType.prototype.ele = function(name, value) {
  2652. return this.element(name, value);
  2653. };
  2654. XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  2655. return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
  2656. };
  2657. XMLDocType.prototype.ent = function(name, value) {
  2658. return this.entity(name, value);
  2659. };
  2660. XMLDocType.prototype.pent = function(name, value) {
  2661. return this.pEntity(name, value);
  2662. };
  2663. XMLDocType.prototype.not = function(name, value) {
  2664. return this.notation(name, value);
  2665. };
  2666. XMLDocType.prototype.dat = function(value) {
  2667. return this.cdata(value);
  2668. };
  2669. XMLDocType.prototype.com = function(value) {
  2670. return this.comment(value);
  2671. };
  2672. XMLDocType.prototype.ins = function(target, value) {
  2673. return this.instruction(target, value);
  2674. };
  2675. XMLDocType.prototype.up = function() {
  2676. return this.root();
  2677. };
  2678. XMLDocType.prototype.doc = function() {
  2679. return this.document();
  2680. };
  2681. return XMLDocType;
  2682. })();
  2683. }).call(this);
  2684. },{"./XMLCData":65,"./XMLComment":66,"./XMLDTDAttList":67,"./XMLDTDElement":68,"./XMLDTDEntity":69,"./XMLDTDNotation":70,"./XMLProcessingInstruction":75,"lodash/lang/isObject":53,"lodash/object/create":57}],73:[function(require,module,exports){
  2685. // Generated by CoffeeScript 1.9.1
  2686. (function() {
  2687. var XMLAttribute, XMLElement, XMLNode, XMLProcessingInstruction, create, every, isFunction, isObject,
  2688. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  2689. hasProp = {}.hasOwnProperty;
  2690. create = require('lodash/object/create');
  2691. isObject = require('lodash/lang/isObject');
  2692. isFunction = require('lodash/lang/isFunction');
  2693. every = require('lodash/collection/every');
  2694. XMLNode = require('./XMLNode');
  2695. XMLAttribute = require('./XMLAttribute');
  2696. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  2697. module.exports = XMLElement = (function(superClass) {
  2698. extend(XMLElement, superClass);
  2699. function XMLElement(parent, name, attributes) {
  2700. XMLElement.__super__.constructor.call(this, parent);
  2701. if (name == null) {
  2702. throw new Error("Missing element name");
  2703. }
  2704. this.name = this.stringify.eleName(name);
  2705. this.children = [];
  2706. this.instructions = [];
  2707. this.attributes = {};
  2708. if (attributes != null) {
  2709. this.attribute(attributes);
  2710. }
  2711. }
  2712. XMLElement.prototype.clone = function() {
  2713. var att, attName, clonedSelf, i, len, pi, ref, ref1;
  2714. clonedSelf = create(XMLElement.prototype, this);
  2715. if (clonedSelf.isRoot) {
  2716. clonedSelf.documentObject = null;
  2717. }
  2718. clonedSelf.attributes = {};
  2719. ref = this.attributes;
  2720. for (attName in ref) {
  2721. if (!hasProp.call(ref, attName)) continue;
  2722. att = ref[attName];
  2723. clonedSelf.attributes[attName] = att.clone();
  2724. }
  2725. clonedSelf.instructions = [];
  2726. ref1 = this.instructions;
  2727. for (i = 0, len = ref1.length; i < len; i++) {
  2728. pi = ref1[i];
  2729. clonedSelf.instructions.push(pi.clone());
  2730. }
  2731. clonedSelf.children = [];
  2732. this.children.forEach(function(child) {
  2733. var clonedChild;
  2734. clonedChild = child.clone();
  2735. clonedChild.parent = clonedSelf;
  2736. return clonedSelf.children.push(clonedChild);
  2737. });
  2738. return clonedSelf;
  2739. };
  2740. XMLElement.prototype.attribute = function(name, value) {
  2741. var attName, attValue;
  2742. if (name != null) {
  2743. name = name.valueOf();
  2744. }
  2745. if (isObject(name)) {
  2746. for (attName in name) {
  2747. if (!hasProp.call(name, attName)) continue;
  2748. attValue = name[attName];
  2749. this.attribute(attName, attValue);
  2750. }
  2751. } else {
  2752. if (isFunction(value)) {
  2753. value = value.apply();
  2754. }
  2755. if (!this.options.skipNullAttributes || (value != null)) {
  2756. this.attributes[name] = new XMLAttribute(this, name, value);
  2757. }
  2758. }
  2759. return this;
  2760. };
  2761. XMLElement.prototype.removeAttribute = function(name) {
  2762. var attName, i, len;
  2763. if (name == null) {
  2764. throw new Error("Missing attribute name");
  2765. }
  2766. name = name.valueOf();
  2767. if (Array.isArray(name)) {
  2768. for (i = 0, len = name.length; i < len; i++) {
  2769. attName = name[i];
  2770. delete this.attributes[attName];
  2771. }
  2772. } else {
  2773. delete this.attributes[name];
  2774. }
  2775. return this;
  2776. };
  2777. XMLElement.prototype.instruction = function(target, value) {
  2778. var i, insTarget, insValue, instruction, len;
  2779. if (target != null) {
  2780. target = target.valueOf();
  2781. }
  2782. if (value != null) {
  2783. value = value.valueOf();
  2784. }
  2785. if (Array.isArray(target)) {
  2786. for (i = 0, len = target.length; i < len; i++) {
  2787. insTarget = target[i];
  2788. this.instruction(insTarget);
  2789. }
  2790. } else if (isObject(target)) {
  2791. for (insTarget in target) {
  2792. if (!hasProp.call(target, insTarget)) continue;
  2793. insValue = target[insTarget];
  2794. this.instruction(insTarget, insValue);
  2795. }
  2796. } else {
  2797. if (isFunction(value)) {
  2798. value = value.apply();
  2799. }
  2800. instruction = new XMLProcessingInstruction(this, target, value);
  2801. this.instructions.push(instruction);
  2802. }
  2803. return this;
  2804. };
  2805. XMLElement.prototype.toString = function(options, level) {
  2806. var att, child, i, indent, instruction, j, len, len1, name, newline, offset, pretty, r, ref, ref1, ref2, ref3, ref4, ref5, space;
  2807. pretty = (options != null ? options.pretty : void 0) || false;
  2808. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  2809. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  2810. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  2811. level || (level = 0);
  2812. space = new Array(level + offset + 1).join(indent);
  2813. r = '';
  2814. ref3 = this.instructions;
  2815. for (i = 0, len = ref3.length; i < len; i++) {
  2816. instruction = ref3[i];
  2817. r += instruction.toString(options, level);
  2818. }
  2819. if (pretty) {
  2820. r += space;
  2821. }
  2822. r += '<' + this.name;
  2823. ref4 = this.attributes;
  2824. for (name in ref4) {
  2825. if (!hasProp.call(ref4, name)) continue;
  2826. att = ref4[name];
  2827. r += att.toString(options);
  2828. }
  2829. if (this.children.length === 0 || every(this.children, function(e) {
  2830. return e.value === '';
  2831. })) {
  2832. r += '/>';
  2833. if (pretty) {
  2834. r += newline;
  2835. }
  2836. } else if (pretty && this.children.length === 1 && (this.children[0].value != null)) {
  2837. r += '>';
  2838. r += this.children[0].value;
  2839. r += '</' + this.name + '>';
  2840. r += newline;
  2841. } else {
  2842. r += '>';
  2843. if (pretty) {
  2844. r += newline;
  2845. }
  2846. ref5 = this.children;
  2847. for (j = 0, len1 = ref5.length; j < len1; j++) {
  2848. child = ref5[j];
  2849. r += child.toString(options, level + 1);
  2850. }
  2851. if (pretty) {
  2852. r += space;
  2853. }
  2854. r += '</' + this.name + '>';
  2855. if (pretty) {
  2856. r += newline;
  2857. }
  2858. }
  2859. return r;
  2860. };
  2861. XMLElement.prototype.att = function(name, value) {
  2862. return this.attribute(name, value);
  2863. };
  2864. XMLElement.prototype.ins = function(target, value) {
  2865. return this.instruction(target, value);
  2866. };
  2867. XMLElement.prototype.a = function(name, value) {
  2868. return this.attribute(name, value);
  2869. };
  2870. XMLElement.prototype.i = function(target, value) {
  2871. return this.instruction(target, value);
  2872. };
  2873. return XMLElement;
  2874. })(XMLNode);
  2875. }).call(this);
  2876. },{"./XMLAttribute":63,"./XMLNode":74,"./XMLProcessingInstruction":75,"lodash/collection/every":5,"lodash/lang/isFunction":51,"lodash/lang/isObject":53,"lodash/object/create":57}],74:[function(require,module,exports){
  2877. // Generated by CoffeeScript 1.9.1
  2878. (function() {
  2879. var XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLElement, XMLNode, XMLRaw, XMLText, isEmpty, isFunction, isObject,
  2880. hasProp = {}.hasOwnProperty;
  2881. isObject = require('lodash/lang/isObject');
  2882. isFunction = require('lodash/lang/isFunction');
  2883. isEmpty = require('lodash/lang/isEmpty');
  2884. XMLElement = null;
  2885. XMLCData = null;
  2886. XMLComment = null;
  2887. XMLDeclaration = null;
  2888. XMLDocType = null;
  2889. XMLRaw = null;
  2890. XMLText = null;
  2891. module.exports = XMLNode = (function() {
  2892. function XMLNode(parent) {
  2893. this.parent = parent;
  2894. this.options = this.parent.options;
  2895. this.stringify = this.parent.stringify;
  2896. if (XMLElement === null) {
  2897. XMLElement = require('./XMLElement');
  2898. XMLCData = require('./XMLCData');
  2899. XMLComment = require('./XMLComment');
  2900. XMLDeclaration = require('./XMLDeclaration');
  2901. XMLDocType = require('./XMLDocType');
  2902. XMLRaw = require('./XMLRaw');
  2903. XMLText = require('./XMLText');
  2904. }
  2905. }
  2906. XMLNode.prototype.element = function(name, attributes, text) {
  2907. var childNode, item, j, k, key, lastChild, len, len1, ref, val;
  2908. lastChild = null;
  2909. if (attributes == null) {
  2910. attributes = {};
  2911. }
  2912. attributes = attributes.valueOf();
  2913. if (!isObject(attributes)) {
  2914. ref = [attributes, text], text = ref[0], attributes = ref[1];
  2915. }
  2916. if (name != null) {
  2917. name = name.valueOf();
  2918. }
  2919. if (Array.isArray(name)) {
  2920. for (j = 0, len = name.length; j < len; j++) {
  2921. item = name[j];
  2922. lastChild = this.element(item);
  2923. }
  2924. } else if (isFunction(name)) {
  2925. lastChild = this.element(name.apply());
  2926. } else if (isObject(name)) {
  2927. for (key in name) {
  2928. if (!hasProp.call(name, key)) continue;
  2929. val = name[key];
  2930. if (isFunction(val)) {
  2931. val = val.apply();
  2932. }
  2933. if ((isObject(val)) && (isEmpty(val))) {
  2934. val = null;
  2935. }
  2936. if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
  2937. lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
  2938. } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && key.indexOf(this.stringify.convertPIKey) === 0) {
  2939. lastChild = this.instruction(key.substr(this.stringify.convertPIKey.length), val);
  2940. } else if (Array.isArray(val)) {
  2941. for (k = 0, len1 = val.length; k < len1; k++) {
  2942. item = val[k];
  2943. childNode = {};
  2944. childNode[key] = item;
  2945. lastChild = this.element(childNode);
  2946. }
  2947. } else if (isObject(val)) {
  2948. lastChild = this.element(key);
  2949. lastChild.element(val);
  2950. } else {
  2951. lastChild = this.element(key, val);
  2952. }
  2953. }
  2954. } else {
  2955. if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
  2956. lastChild = this.text(text);
  2957. } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
  2958. lastChild = this.cdata(text);
  2959. } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
  2960. lastChild = this.comment(text);
  2961. } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
  2962. lastChild = this.raw(text);
  2963. } else {
  2964. lastChild = this.node(name, attributes, text);
  2965. }
  2966. }
  2967. if (lastChild == null) {
  2968. throw new Error("Could not create any elements with: " + name);
  2969. }
  2970. return lastChild;
  2971. };
  2972. XMLNode.prototype.insertBefore = function(name, attributes, text) {
  2973. var child, i, removed;
  2974. if (this.isRoot) {
  2975. throw new Error("Cannot insert elements at root level");
  2976. }
  2977. i = this.parent.children.indexOf(this);
  2978. removed = this.parent.children.splice(i);
  2979. child = this.parent.element(name, attributes, text);
  2980. Array.prototype.push.apply(this.parent.children, removed);
  2981. return child;
  2982. };
  2983. XMLNode.prototype.insertAfter = function(name, attributes, text) {
  2984. var child, i, removed;
  2985. if (this.isRoot) {
  2986. throw new Error("Cannot insert elements at root level");
  2987. }
  2988. i = this.parent.children.indexOf(this);
  2989. removed = this.parent.children.splice(i + 1);
  2990. child = this.parent.element(name, attributes, text);
  2991. Array.prototype.push.apply(this.parent.children, removed);
  2992. return child;
  2993. };
  2994. XMLNode.prototype.remove = function() {
  2995. var i, ref;
  2996. if (this.isRoot) {
  2997. throw new Error("Cannot remove the root element");
  2998. }
  2999. i = this.parent.children.indexOf(this);
  3000. [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref = [])), ref;
  3001. return this.parent;
  3002. };
  3003. XMLNode.prototype.node = function(name, attributes, text) {
  3004. var child, ref;
  3005. if (name != null) {
  3006. name = name.valueOf();
  3007. }
  3008. if (attributes == null) {
  3009. attributes = {};
  3010. }
  3011. attributes = attributes.valueOf();
  3012. if (!isObject(attributes)) {
  3013. ref = [attributes, text], text = ref[0], attributes = ref[1];
  3014. }
  3015. child = new XMLElement(this, name, attributes);
  3016. if (text != null) {
  3017. child.text(text);
  3018. }
  3019. this.children.push(child);
  3020. return child;
  3021. };
  3022. XMLNode.prototype.text = function(value) {
  3023. var child;
  3024. child = new XMLText(this, value);
  3025. this.children.push(child);
  3026. return this;
  3027. };
  3028. XMLNode.prototype.cdata = function(value) {
  3029. var child;
  3030. child = new XMLCData(this, value);
  3031. this.children.push(child);
  3032. return this;
  3033. };
  3034. XMLNode.prototype.comment = function(value) {
  3035. var child;
  3036. child = new XMLComment(this, value);
  3037. this.children.push(child);
  3038. return this;
  3039. };
  3040. XMLNode.prototype.raw = function(value) {
  3041. var child;
  3042. child = new XMLRaw(this, value);
  3043. this.children.push(child);
  3044. return this;
  3045. };
  3046. XMLNode.prototype.declaration = function(version, encoding, standalone) {
  3047. var doc, xmldec;
  3048. doc = this.document();
  3049. xmldec = new XMLDeclaration(doc, version, encoding, standalone);
  3050. doc.xmldec = xmldec;
  3051. return doc.root();
  3052. };
  3053. XMLNode.prototype.doctype = function(pubID, sysID) {
  3054. var doc, doctype;
  3055. doc = this.document();
  3056. doctype = new XMLDocType(doc, pubID, sysID);
  3057. doc.doctype = doctype;
  3058. return doctype;
  3059. };
  3060. XMLNode.prototype.up = function() {
  3061. if (this.isRoot) {
  3062. throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
  3063. }
  3064. return this.parent;
  3065. };
  3066. XMLNode.prototype.root = function() {
  3067. var child;
  3068. if (this.isRoot) {
  3069. return this;
  3070. }
  3071. child = this.parent;
  3072. while (!child.isRoot) {
  3073. child = child.parent;
  3074. }
  3075. return child;
  3076. };
  3077. XMLNode.prototype.document = function() {
  3078. return this.root().documentObject;
  3079. };
  3080. XMLNode.prototype.end = function(options) {
  3081. return this.document().toString(options);
  3082. };
  3083. XMLNode.prototype.prev = function() {
  3084. var i;
  3085. if (this.isRoot) {
  3086. throw new Error("Root node has no siblings");
  3087. }
  3088. i = this.parent.children.indexOf(this);
  3089. if (i < 1) {
  3090. throw new Error("Already at the first node");
  3091. }
  3092. return this.parent.children[i - 1];
  3093. };
  3094. XMLNode.prototype.next = function() {
  3095. var i;
  3096. if (this.isRoot) {
  3097. throw new Error("Root node has no siblings");
  3098. }
  3099. i = this.parent.children.indexOf(this);
  3100. if (i === -1 || i === this.parent.children.length - 1) {
  3101. throw new Error("Already at the last node");
  3102. }
  3103. return this.parent.children[i + 1];
  3104. };
  3105. XMLNode.prototype.importXMLBuilder = function(xmlbuilder) {
  3106. var clonedRoot;
  3107. clonedRoot = xmlbuilder.root().clone();
  3108. clonedRoot.parent = this;
  3109. clonedRoot.isRoot = false;
  3110. this.children.push(clonedRoot);
  3111. return this;
  3112. };
  3113. XMLNode.prototype.ele = function(name, attributes, text) {
  3114. return this.element(name, attributes, text);
  3115. };
  3116. XMLNode.prototype.nod = function(name, attributes, text) {
  3117. return this.node(name, attributes, text);
  3118. };
  3119. XMLNode.prototype.txt = function(value) {
  3120. return this.text(value);
  3121. };
  3122. XMLNode.prototype.dat = function(value) {
  3123. return this.cdata(value);
  3124. };
  3125. XMLNode.prototype.com = function(value) {
  3126. return this.comment(value);
  3127. };
  3128. XMLNode.prototype.doc = function() {
  3129. return this.document();
  3130. };
  3131. XMLNode.prototype.dec = function(version, encoding, standalone) {
  3132. return this.declaration(version, encoding, standalone);
  3133. };
  3134. XMLNode.prototype.dtd = function(pubID, sysID) {
  3135. return this.doctype(pubID, sysID);
  3136. };
  3137. XMLNode.prototype.e = function(name, attributes, text) {
  3138. return this.element(name, attributes, text);
  3139. };
  3140. XMLNode.prototype.n = function(name, attributes, text) {
  3141. return this.node(name, attributes, text);
  3142. };
  3143. XMLNode.prototype.t = function(value) {
  3144. return this.text(value);
  3145. };
  3146. XMLNode.prototype.d = function(value) {
  3147. return this.cdata(value);
  3148. };
  3149. XMLNode.prototype.c = function(value) {
  3150. return this.comment(value);
  3151. };
  3152. XMLNode.prototype.r = function(value) {
  3153. return this.raw(value);
  3154. };
  3155. XMLNode.prototype.u = function() {
  3156. return this.up();
  3157. };
  3158. return XMLNode;
  3159. })();
  3160. }).call(this);
  3161. },{"./XMLCData":65,"./XMLComment":66,"./XMLDeclaration":71,"./XMLDocType":72,"./XMLElement":73,"./XMLRaw":76,"./XMLText":78,"lodash/lang/isEmpty":50,"lodash/lang/isFunction":51,"lodash/lang/isObject":53}],75:[function(require,module,exports){
  3162. // Generated by CoffeeScript 1.9.1
  3163. (function() {
  3164. var XMLProcessingInstruction, create;
  3165. create = require('lodash/object/create');
  3166. module.exports = XMLProcessingInstruction = (function() {
  3167. function XMLProcessingInstruction(parent, target, value) {
  3168. this.stringify = parent.stringify;
  3169. if (target == null) {
  3170. throw new Error("Missing instruction target");
  3171. }
  3172. this.target = this.stringify.insTarget(target);
  3173. if (value) {
  3174. this.value = this.stringify.insValue(value);
  3175. }
  3176. }
  3177. XMLProcessingInstruction.prototype.clone = function() {
  3178. return create(XMLProcessingInstruction.prototype, this);
  3179. };
  3180. XMLProcessingInstruction.prototype.toString = function(options, level) {
  3181. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  3182. pretty = (options != null ? options.pretty : void 0) || false;
  3183. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  3184. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  3185. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  3186. level || (level = 0);
  3187. space = new Array(level + offset + 1).join(indent);
  3188. r = '';
  3189. if (pretty) {
  3190. r += space;
  3191. }
  3192. r += '<?';
  3193. r += this.target;
  3194. if (this.value) {
  3195. r += ' ' + this.value;
  3196. }
  3197. r += '?>';
  3198. if (pretty) {
  3199. r += newline;
  3200. }
  3201. return r;
  3202. };
  3203. return XMLProcessingInstruction;
  3204. })();
  3205. }).call(this);
  3206. },{"lodash/object/create":57}],76:[function(require,module,exports){
  3207. // Generated by CoffeeScript 1.9.1
  3208. (function() {
  3209. var XMLNode, XMLRaw, create,
  3210. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  3211. hasProp = {}.hasOwnProperty;
  3212. create = require('lodash/object/create');
  3213. XMLNode = require('./XMLNode');
  3214. module.exports = XMLRaw = (function(superClass) {
  3215. extend(XMLRaw, superClass);
  3216. function XMLRaw(parent, text) {
  3217. XMLRaw.__super__.constructor.call(this, parent);
  3218. if (text == null) {
  3219. throw new Error("Missing raw text");
  3220. }
  3221. this.value = this.stringify.raw(text);
  3222. }
  3223. XMLRaw.prototype.clone = function() {
  3224. return create(XMLRaw.prototype, this);
  3225. };
  3226. XMLRaw.prototype.toString = function(options, level) {
  3227. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  3228. pretty = (options != null ? options.pretty : void 0) || false;
  3229. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  3230. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  3231. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  3232. level || (level = 0);
  3233. space = new Array(level + offset + 1).join(indent);
  3234. r = '';
  3235. if (pretty) {
  3236. r += space;
  3237. }
  3238. r += this.value;
  3239. if (pretty) {
  3240. r += newline;
  3241. }
  3242. return r;
  3243. };
  3244. return XMLRaw;
  3245. })(XMLNode);
  3246. }).call(this);
  3247. },{"./XMLNode":74,"lodash/object/create":57}],77:[function(require,module,exports){
  3248. // Generated by CoffeeScript 1.9.1
  3249. (function() {
  3250. var XMLStringifier,
  3251. bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  3252. hasProp = {}.hasOwnProperty;
  3253. module.exports = XMLStringifier = (function() {
  3254. function XMLStringifier(options) {
  3255. this.assertLegalChar = bind(this.assertLegalChar, this);
  3256. var key, ref, value;
  3257. this.allowSurrogateChars = options != null ? options.allowSurrogateChars : void 0;
  3258. ref = (options != null ? options.stringify : void 0) || {};
  3259. for (key in ref) {
  3260. if (!hasProp.call(ref, key)) continue;
  3261. value = ref[key];
  3262. this[key] = value;
  3263. }
  3264. }
  3265. XMLStringifier.prototype.eleName = function(val) {
  3266. val = '' + val || '';
  3267. return this.assertLegalChar(val);
  3268. };
  3269. XMLStringifier.prototype.eleText = function(val) {
  3270. val = '' + val || '';
  3271. return this.assertLegalChar(this.elEscape(val));
  3272. };
  3273. XMLStringifier.prototype.cdata = function(val) {
  3274. val = '' + val || '';
  3275. if (val.match(/]]>/)) {
  3276. throw new Error("Invalid CDATA text: " + val);
  3277. }
  3278. return this.assertLegalChar(val);
  3279. };
  3280. XMLStringifier.prototype.comment = function(val) {
  3281. val = '' + val || '';
  3282. if (val.match(/--/)) {
  3283. throw new Error("Comment text cannot contain double-hypen: " + val);
  3284. }
  3285. return this.assertLegalChar(val);
  3286. };
  3287. XMLStringifier.prototype.raw = function(val) {
  3288. return '' + val || '';
  3289. };
  3290. XMLStringifier.prototype.attName = function(val) {
  3291. return '' + val || '';
  3292. };
  3293. XMLStringifier.prototype.attValue = function(val) {
  3294. val = '' + val || '';
  3295. return this.attEscape(val);
  3296. };
  3297. XMLStringifier.prototype.insTarget = function(val) {
  3298. return '' + val || '';
  3299. };
  3300. XMLStringifier.prototype.insValue = function(val) {
  3301. val = '' + val || '';
  3302. if (val.match(/\?>/)) {
  3303. throw new Error("Invalid processing instruction value: " + val);
  3304. }
  3305. return val;
  3306. };
  3307. XMLStringifier.prototype.xmlVersion = function(val) {
  3308. val = '' + val || '';
  3309. if (!val.match(/1\.[0-9]+/)) {
  3310. throw new Error("Invalid version number: " + val);
  3311. }
  3312. return val;
  3313. };
  3314. XMLStringifier.prototype.xmlEncoding = function(val) {
  3315. val = '' + val || '';
  3316. if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-]|-)*$/)) {
  3317. throw new Error("Invalid encoding: " + val);
  3318. }
  3319. return val;
  3320. };
  3321. XMLStringifier.prototype.xmlStandalone = function(val) {
  3322. if (val) {
  3323. return "yes";
  3324. } else {
  3325. return "no";
  3326. }
  3327. };
  3328. XMLStringifier.prototype.dtdPubID = function(val) {
  3329. return '' + val || '';
  3330. };
  3331. XMLStringifier.prototype.dtdSysID = function(val) {
  3332. return '' + val || '';
  3333. };
  3334. XMLStringifier.prototype.dtdElementValue = function(val) {
  3335. return '' + val || '';
  3336. };
  3337. XMLStringifier.prototype.dtdAttType = function(val) {
  3338. return '' + val || '';
  3339. };
  3340. XMLStringifier.prototype.dtdAttDefault = function(val) {
  3341. if (val != null) {
  3342. return '' + val || '';
  3343. } else {
  3344. return val;
  3345. }
  3346. };
  3347. XMLStringifier.prototype.dtdEntityValue = function(val) {
  3348. return '' + val || '';
  3349. };
  3350. XMLStringifier.prototype.dtdNData = function(val) {
  3351. return '' + val || '';
  3352. };
  3353. XMLStringifier.prototype.convertAttKey = '@';
  3354. XMLStringifier.prototype.convertPIKey = '?';
  3355. XMLStringifier.prototype.convertTextKey = '#text';
  3356. XMLStringifier.prototype.convertCDataKey = '#cdata';
  3357. XMLStringifier.prototype.convertCommentKey = '#comment';
  3358. XMLStringifier.prototype.convertRawKey = '#raw';
  3359. XMLStringifier.prototype.assertLegalChar = function(str) {
  3360. var chars, chr;
  3361. if (this.allowSurrogateChars) {
  3362. chars = /[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uFFFE-\uFFFF]/;
  3363. } else {
  3364. chars = /[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE-\uFFFF]/;
  3365. }
  3366. chr = str.match(chars);
  3367. if (chr) {
  3368. throw new Error("Invalid character (" + chr + ") in string: " + str + " at index " + chr.index);
  3369. }
  3370. return str;
  3371. };
  3372. XMLStringifier.prototype.elEscape = function(str) {
  3373. return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\r/g, '&#xD;');
  3374. };
  3375. XMLStringifier.prototype.attEscape = function(str) {
  3376. return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;');
  3377. };
  3378. return XMLStringifier;
  3379. })();
  3380. }).call(this);
  3381. },{}],78:[function(require,module,exports){
  3382. // Generated by CoffeeScript 1.9.1
  3383. (function() {
  3384. var XMLNode, XMLText, create,
  3385. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  3386. hasProp = {}.hasOwnProperty;
  3387. create = require('lodash/object/create');
  3388. XMLNode = require('./XMLNode');
  3389. module.exports = XMLText = (function(superClass) {
  3390. extend(XMLText, superClass);
  3391. function XMLText(parent, text) {
  3392. XMLText.__super__.constructor.call(this, parent);
  3393. if (text == null) {
  3394. throw new Error("Missing element text");
  3395. }
  3396. this.value = this.stringify.eleText(text);
  3397. }
  3398. XMLText.prototype.clone = function() {
  3399. return create(XMLText.prototype, this);
  3400. };
  3401. XMLText.prototype.toString = function(options, level) {
  3402. var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
  3403. pretty = (options != null ? options.pretty : void 0) || false;
  3404. indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
  3405. offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
  3406. newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
  3407. level || (level = 0);
  3408. space = new Array(level + offset + 1).join(indent);
  3409. r = '';
  3410. if (pretty) {
  3411. r += space;
  3412. }
  3413. r += this.value;
  3414. if (pretty) {
  3415. r += newline;
  3416. }
  3417. return r;
  3418. };
  3419. return XMLText;
  3420. })(XMLNode);
  3421. }).call(this);
  3422. },{"./XMLNode":74,"lodash/object/create":57}],79:[function(require,module,exports){
  3423. // Generated by CoffeeScript 1.9.1
  3424. (function() {
  3425. var XMLBuilder, assign;
  3426. assign = require('lodash/object/assign');
  3427. XMLBuilder = require('./XMLBuilder');
  3428. module.exports.create = function(name, xmldec, doctype, options) {
  3429. options = assign({}, xmldec, doctype, options);
  3430. return new XMLBuilder(name, options).root();
  3431. };
  3432. }).call(this);
  3433. },{"./XMLBuilder":64,"lodash/object/assign":56}]},{},[1])(1)
  3434. });