UNPKG

13.4 kBJavaScriptView Raw
1var XMLLite=function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return t[o].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="/",e(0)}([function(t,e,n){"use strict";mocha.setup("bdd"),n(34),n(35),n(36),n(39),n(40),mocha.run()},,function(t,e){t.exports=jQuery},,function(t,e){t.exports=XMLLite},function(t,e,n){"use strict";var o=n(6),r=n(9),i=n(8),u=n(10),c=n(11),f=n(7);t.exports=u.extend({global:r},o,i,u,c,f)},function(t,e,n){"use strict";function o(t){return"object"===("undefined"==typeof t?"undefined":a(t))&&d.isFinite(t.length)}function r(t){return o(t)?g.call(t):[]}function i(t){return g.call(t,1)}function u(t,e,n){return t.apply(e,i(n))}function c(t,e){return p(r(t),e)>-1}function f(t){var e=[];return N(t,function(t){c(e,t)||e.push(t)}),e}function l(t){for(var e=r(t),n=[],i=0,u=e.length;i<u;++i)o(e[i])?n=n.concat(e[i]):n[n.length]=e[i];return n}var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s=n(7),d=n(8),m=s.isArray,h=Array.prototype,g=h.slice,y=function(t){return function(e,n,o){var r=void 0,i=e.length>>>0;if(0===i)return-1;if(o?o<0&&(o=Math.max(0,e.length+o)):o=t?0:e.length,t){for(r=o;r<e.length;r++)if(e[r]===n)return r}else for(r=o;r>=0;r--)if(e[r]===n)return r;return-1}},p=h.indexOf?function(t){return u(h.indexOf,t,arguments)}:y(!0),b=h.lastIndexOf?function(t){return u(h.lastIndexOf,t,arguments)}:y(),N=h.forEach?function(t){u(h.forEach,t,arguments)}:function(t,e,n){for(var o=r(t),i=0;i<o.length;i++)e.call(n,o[i],i,t)},v=h.every?function(t){return u(h.every,t,arguments)}:function(t,e,n){for(var o=r(t),i=0;i<o.length;i++)if(!e.call(n,o[i],i,t))return!1;return!0},x=h.filter?function(t){return u(h.filter,t,arguments)}:function(t,e,n){var o=[];return N(t,function(r,i){e.call(n,r,i,t)&&o.push(r)}),o},w=h.map?function(t){return u(h.map,t,arguments)}:function(t,e,n){var o=[];return N(t,function(r,i){o.push(e.call(n,r,i,t))}),o},L=h.some?function(t){return u(h.some,t,arguments)}:function(t,e,n){var o=void 0;for(o=0;o<t.length;o++)if(e.call(n,t[o],o,t))return!0;return!1},j=h.reduce?function(t){return u(h.reduce,t,arguments)}:function(t,e,n){var o=void 0;n&&(o=n);for(var r=0;r<t.length;r++)o=o?e(o,t[r],r,t):t[r];return o},k=h.reduceRight?function(t){return u(h.reduceRight,t,arguments)}:function(t,e,n){var o=void 0;n&&(o=n);for(var r=t.length-1;r>=0;r--)o=o?e(o,t[r],r,t):t[r];return o},q={contains:c,each:N,every:v,filter:x,flatten:l,index:y,indexOf:p,isArray:m,isArrayLike:o,lastIndexOf:b,map:w,reduce:j,reduceRight:k,some:L,toArray:r,uniq:f,forEach:N,difference:function(t){var e=l(i(arguments));return x(t,function(t){return!c(e,t)})},eachReverse:function(t,e,n){for(var o=r(t),i=o.length-1;i>-1;i-=1)e.call(n,o[i],i,t)},intersect:function(t,e){var n=[];return N(t,function(t){c(e,t)&&n.push(t)}),n},range:function t(e,n,o){null==n&&(n=e||0,e=0),o||(o=n<e?-1:1);for(var r=Math.max(Math.ceil((n-e)/o),0),t=new Array(r),i=0;i<r;i++,e+=o)t[i]=e;return t},remove:function(t,e,n){var o=t.length;if(!d.isNumber(e))return t;var r=t.slice((n||e)+1||o);return t.length=e<0?o+e:e,t.push.apply(t,r)},union:function(){var t=[],e=r(arguments);return N(e,function(e){t=t.concat(e)}),f(t)}};t.exports=q},function(t,e){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o={}.toString,r=function(t,e){return o.call(t)==="[object "+e+"]"},i={isType:r,isArguments:function(t){return r(t,"Arguments")},isArray:Array.isArray?Array.isArray:function(t){return r(t,"Array")},isArrayLike:function(t){return"object"===("undefined"==typeof t?"undefined":n(t))&&isFinite(t.length)},isBoolean:function(t){return r(t,"Boolean")},isDate:function(t){return r(t,"Date")},isError:function(t){return r(t,"Error")},isFunction:function(t){return r(t,"Function")},isNull:function(t){return null===t},isNumber:function(t){return r(t,"Number")},isPlainObject:function(t){return r(t,"Object")},isRegExp:function(t){return r(t,"RegExp")},isString:function(t){return r(t,"String")},isUndefined:function(t){return void 0===t},getType:function(t){var e=o.call(t);return e.replace(/^\[object /,"").replace(/\]$/,"")},isObject:function(t){var e="undefined"==typeof t?"undefined":n(t);return"function"===e||"object"===e&&!!t}};i.isNil=function(t){return i.isNull(t)||i.isUndefined(t)},t.exports=i},function(t,e,n){"use strict";var o=n(7),r=o.isNumber,i=Math.min,u=Math.max,c={isFinite:isFinite,isNaN:isNaN,isNumber:r,isDecimal:function(t){return r(t)&&t%1!==0},isEven:function(t){return r(t)&&t%2===0},isInteger:Number.isInteger?Number.isInteger:function(t){return r(t)&&t%1===0},isNegative:function(t){return r(t)&&t<0},isOdd:function(t){return r(t)&&t%2!==0},isPositive:function(t){return r(t)&&t>0},toFloat:function(t){return parseFloat(t)},toInteger:function(t,e){return parseInt(t,e||10)},isInRange:function(t,e,n){return e=+e||0,void 0===n?(n=e,e=0):n=+n||0,t>=i(e,n)&&t<u(e,n)}};c.isInFinite=function(t){return!c.isFinite(t)},t.exports=c},function(t,e){(function(e){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o="undefined",r={};("undefined"==typeof window?"undefined":n(window))!==o?r=window:("undefined"==typeof e?"undefined":n(e))!==o?r=e:("undefined"==typeof self?"undefined":n(self))!==o&&(r=self),t.exports=r}).call(e,function(){return this}())},function(t,e,n){"use strict";function o(t){return d(t)?t:{}}function r(t,e,n){var r=o(t);for(var i in r)({}).hasOwnProperty.call(r,i)&&e.call(n,r[i],i,t)}function i(t){var e=[];return r(t,function(t){e.push(t)}),e}function u(t){return t=t||{},g(p(arguments).slice(1),function(e){e&&r(e,function(n,o){t[o]=e[o]})}),t}function c(t){return t=t||{},g(p(arguments).slice(1),function(e){r(e,function(n,o){l(e[o])!==l(t[o])?d(e[o])?(t[o]={},c(t[o],e[o])):t[o]=e[o]:d(e[o])?c(t[o],e[o]):t[o]=e[o]})}),t}var f=n(7),l=f.getType,a=f.isFunction,s=f.isObject,d=f.isPlainObject,m=n(6),h=m.contains,g=m.each,y=m.isArrayLike,p=m.toArray,b=Object.keys?function(t){return Object.keys(t)}:function(t){var e=[];return r(t,function(n,o){a(t)&&"prototype"===o||e.push(o)}),e},N={extend:u,forIn:r,isObject:s,isPlainObject:d,keys:b,merge:c,values:i,assign:u,hasKey:function(t,e){return{}.hasOwnProperty.call(t,e)},hasValue:function(t,e){return h(i(t),e)},invert:function(t){var e={};return r(t,function(t,n){e[t]=n}),e},clone:function(t){return y(t)?p(t):d(t)?c({},t):t},destroy:function(t){r(t,function(e,n){delete t[n]}),t.prototype=null,t=null}};t.exports=N},function(t,e,n){"use strict";function o(t){return t.toString()}var r=n(7),i=r.isString,u=String.prototype,c={isString:i,trim:function(t){return t=o(t),u.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},trimLeft:function(t){return t=o(t),u.trimLeft?t.trimLeft():t.replace(/^\s+/g,"")},trimRight:function(t){return t=o(t),u.trimRight?t.trimRight():t.replace(/^\s+/g,"")},lc:function(t){return o(t).toLowerCase()},uc:function(t){return o(t).toUpperCase()},hasSubString:function(t,e){return o(t).indexOf(o(e))>-1}};t.exports=c},,,,,,,,,,,,,,,,,,,,,,,function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}var r=n(4),i=o(r),u=chai.assert;describe("dom2js",function(){var t=document.createElement("div");t.innerHTML='hello, world!\n<a href="https://github.com/leungwensen/xml-lite">\n maintaining xml in pure javascript (IN BOTH NODE.JS & BROWSERS)\n</a>',t.setAttribute("class","test-div"),t.setAttribute("data-hello","world");var e=i.default.dom2js(t);it("Element: type and tag",function(){u.equal(e.type,t.ELEMENT_NODE,"XMLLite.dom2js() not working: type is not right."),u.equal(e.tag,"DIV","XMLLite.dom2js() not working: tag is not right.")}),it("Element: attributes",function(){u.deepEqual(e.attributes,{class:"test-div","data-hello":"world"},"XMLLite.dom2js() not working: something wrong with the attributes.")})})},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}var r=n(4),i=o(r),u=n(2),c=o(u),f=chai.assert;describe("dom-utils",function(){c.default.get("./fixtures/bookstore.xml",function(t){var e=i.default.parse(t);it("dom-utils: attributesAsObject(doc)",function(){f.deepEqual(i.default.attributesAsObject(i.default.findNodes(e,{tagName:"book",attributes:{category:"COOKING"}})[0]),{category:"COOKING"},"XMLLite.attributesAsObject(doc) not working: something wrong.")}),it("dom-utils: findChildNode(doc, query)",function(){f.equal(i.default.findChildNode(e,{nodeName:"PITarget"}).nodeName,"PITarget","XMLLite.findChildNode(doc, query) not working: not exists.")}),it("dom-utils: findChildNodes(doc, query)",function(){f.equal(i.default.findChildNodes(i.default.findChildNode(e,{tagName:"bookstore"}),{tagName:"book"}).length,3,"XMLLite.findChildNodes(doc, query) not working: result nodes count not matching.")}),it("dom-utils: findAllNodes(doc, query)",function(){f.equal(i.default.findAllNodes(i.default.findChildNode(e,{tagName:"bookstore"}),{tagName:"price"}).length,3,"XMLLite.findAllNodes(doc, query) not working: result nodes count not matching.")}),it("dom-utils: findChildNodes(doc, query) on an element that has no childNodes",function(){f.equal(i.default.findChildNodes(e.childNodes[0],{tagName:"book"}).length,0,"XMLLite.findChildNodes(doc, query) not working: result nodes count not matching.")}),it("dom-utils: createChildNode(doc, query)",function(){f.equal(i.default.createChildNode(e.documentElement,{tagName:"test"}).tagName,"test","XMLLite.createChildNode(doc, query) not working: failed.")}),it("dom-utils: findOrCreateChildNode(doc, query)",function(){f.equal(i.default.findOrCreateChildNode(e.documentElement,{tagName:"test"}).tagName,"test","XMLLite.findOrCreateChildNode(doc, query) not working: failed.")}),it("dom-utils: eachChildNode(doc, query, callback)",function(){f.doesNotThrow(function(){i.default.eachChildNode(e,{},function(t){console.log(t.nodeName)})},Error,"XMLLite.eachChildNode(doc, query, callback) not working: failed.")}),it("dom-utils: eachNode(doc, query, callback)",function(){f.doesNotThrow(function(){i.default.eachNode(e,{},function(t){console.log(t.nodeName)})},Error,"XMLLite.eachChildNode(doc, query, callback) not working: failed.")}),it("dom-utils: removeChildNode(doc, query)",function(){var t=e.childNodes.length;console.log(e.childNodes),f.doesNotThrow(function(){i.default.removeChildNode(e,{nodeName:"PITarget"})},Error,"XMLLite.eachChildNode(doc, query, callback) not working: failed."),f.equal(e.childNodes.length,t-1,"XMLLite.removeChildNode(doc, query) not working: failed."),console.log(e.childNodes)})},"text")})},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}var r=n(2),i=o(r),u=n(4),c=o(u),f=n(37),l=o(f),a=n(38),s=o(a),d=chai.assert;describe("js2xml",function(){function t(e){e.length&&!function(){var n=e.shift();it("js2xml: spec/fixtures/"+n+".xml",function(t){i.default.get("./fixtures/"+n+".xml",function(e){i.default.get("./fixtures/"+n+".json",function(o){var r=Date.now();c.default.js2xml(o);var i=Date.now()-r,u=(0,l.default)(o);console.log("%cjs2xml: %c%sms %cto render %c%s %celements in fixture "+n+".","font-weight: bold; color: blue;","font-weight: bold; color: green;",(0,s.default)(i,3),"font-weight: normal; color: black;","font-weight: bold; color: red;",(0,s.default)(u,4),"font-weight: normal; color: black;"),"mmap-content"!==n&&d.equal(c.default.js2xml(o),c.default.uglify(e),"test case by fixture "+n+" not passed"),t()})},"text")}),t(e)}()}this.timeout(1e4),i.default.get("./fixtures/files.json",function(e){t(e)})})},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}var r=n(5),i=o(r);t.exports=function(t){function e(t){"Document"!==t.type&&"TextNode"!==t.type&&n++,t.children&&i.default.each(t.children,function(t){e(t)})}var n=0;return e(t),n}},function(t,e){"use strict";t.exports=function(t,e,n){n=n||" ";for(var o=t.toString();o.length<e;)o=n+o;return o}},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}var r=n(2),i=o(r),u=n(4),c=o(u),f=n(37),l=o(f),a=n(38),s=o(a),d=chai.assert;describe("xml2js",function(){function t(e){e.length&&!function(){var n=e.shift();it("xml2js: spec/fixtures/"+n+".xml",function(t){i.default.get("./fixtures/"+n+".xml",function(e){i.default.get("./fixtures/"+n+".json",function(o){var r=Date.now(),i=c.default.xml2js(e),u=Date.now()-r,f=(0,l.default)(i);console.log("%cxml2js: %c%sms %cto parse %c%s %celements in fixture "+n+".","font-weight: bold; color: blue;","font-weight: bold; color: green;",(0,s.default)(u,3),"font-weight: normal; color: black;","font-weight: bold; color: red;",(0,s.default)(f,5),"font-weight: normal; color: black;"),d.deepEqual(c.default.xml2js(e),o,"test case by fixture "+n+" not passed"),t()})},"text")}),t(e)}()}this.timeout(1e4),i.default.get("./fixtures/files.json",function(e){t(e)})})},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}var r=n(4),i=o(r),u=chai.assert;describe("error tracking",function(){it("XMLLite.parse(xmlString): non-xml string",function(){u.throws(function(){i.default.parse("some text")},"")})})}]);
\No newline at end of file