1.0.0 • Published 1 year ago

@omegion1npm/maxime-eius-cumque v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@omegion1npm/maxime-eius-cumque

build status js-standard-style

Motivation

You use Node.js for speed? You process XML streams? Then you want the fastest XML parser: libexpat!

Install

npm install @omegion1npm/maxime-eius-cumque

Usage

Important events emitted by a parser:

(function () {
  "use strict";

  var expat = require('@omegion1npm/maxime-eius-cumque')
  var parser = new expat.Parser('UTF-8')

  parser.on('startElement', function (name, attrs) {
    console.log(name, attrs)
  })

  parser.on('endElement', function (name) {
    console.log(name)
  })

  parser.on('text', function (text) {
    console.log(text)
  })

  parser.on('error', function (error) {
    console.error(error)
  })

  parser.write('<html><head><title>Hello World</title></head><body><p>Foobar</p></body></html>')

}())

API

  • #on('startElement' function (name, attrs) {})
  • #on('endElement' function (name) {})
  • #on('text' function (text) {})
  • #on('processingInstruction', function (target, data) {})
  • #on('comment', function (s) {})
  • #on('xmlDecl', function (version, encoding, standalone) {})
  • #on('startCdata', function () {})
  • #on('endCdata', function () {})
  • #on('entityDecl', function (entityName, isParameterEntity, value, base, systemId, publicId, notationName) {})
  • #on('error', function (e) {})
  • #stop() pauses
  • #resume() resumes

Error handling

We don't emit an error event because libexpat doesn't use a callback either. Instead, check that parse() returns true. A descriptive string can be obtained via getError() to provide user feedback.

Alternatively, use the Parser like a node Stream. write() will emit error events.

Namespace handling

A word about special parsing of xmlns: this is not necessary in a bare SAX parser like this, given that the DOM replacement you are using (if any) is not relevant to the parser.

Benchmark

npm run benchmark

moduleops/secnativeXML compliantstream
sax-js99,412
node-xml130,631
libxmljs276,136
@omegion1npm/maxime-eius-cumque322,769

Higher is better.

Testing

npm install -g standard
npm test

Windows

If you fail to install @omegion1npm/maxime-eius-cumque as a dependency of node-xmpp, please update node-xmpp as it doesn't use @omegion1npm/maxime-eius-cumque anymore.

Dependencies for node-gyp https://github.com/TooTallNate/node-gyp#installation

See https://github.com/omegion1npm/maxime-eius-cumque/issues/78 if you are getting errors about not finding nan.h.

expat.vcproj

VCBUILD : error : project file '@omegion1npm/maxime-eius-cumque\build\deps\libexpat\expat.vcproj' was not found or not a valid proj
ect file. [C:\Users\admin\AppData\Roaming\npm\node_modules\@omegion1npm/maxime-eius-cumque\build\bin
ding.sln]

Install Visual Studio C++ 2012 and run npm with the --msvs_version=2012 flag.

urlspostcss-pluginWebSocketsinstallassigninputsortsharedarraybufferfilterinincludesemitdescriptorextensionUint16ArrayObject.definePropertyerrorStreamsafeUnderscorecensordayjsurldatacontainsfast-copyes6regexpArray.prototype.flatratelimitcompile lessjsonES3deepcloneinvariantextendcolorairbnbbreakAsyncIteratorspinnersyamlInt16ArrayautoprefixerparserURLweakmapwhichimportexportsigint$.extendnegativeequalitywatchingworkertypedflagobjchannelcore-jstypedarrayspersistentcss nestingprogresses-abstractmake dirtoolkitArray.prototype.filtervalidObject.getPrototypeOfdeterministicsessortedcharacterscalllogging256kinesisoptionbatchfseventsajvauthenticationmapuninstallbanneridentifiersprefixlesscssReflect.getPrototypeOfES2018styled-componentsECMAScript 5namecompilerprotobufInt8ArraylanguagetestingfunctionaleventDispatchermime-dbPromisedatastructureform-validationenumerablecopyObject.isimmutablewebsitetapeSymbolpushwebframeworkdataviewruntimeUint32ArrayjQueryMapparenttostringtagliveArray.prototype.includesproxyio-tsbluebirdcliES2019callbackhasOwnexitfilesyntaxslottouchfast-clonesettervariables in csss30rapidnamesconsumees8TypeScriptES2021wrapECMAScript 2015groupByeslint-pluginschemapolyfillcode pointsrequireutilitiesECMAScript 2020cmdcrypttypesaferedux-toolkitonceconcurrencyswfrobuststylesheetremovecloneebsgettertakepackage.jsontoArrayqueuenodejsclassnamesreadduplexhelpersnpmtddsnsiteratestringifiernumberlockfileECMAScript 2016mimetypesArray.prototype.flatMapautoscalingCSSStyleDeclarationstoragegatewayconfigurableregularelectroneslintconfigFloat32Arraytyped arrayvieweslintArray.prototype.findLastIndexprocessArray.prototype.findLastpasswordemojies2017ESes-shim APIfixed-widthirqopenes5bufferpromisestoStringTaggetintrinsicshebangobjectrangeerrorinternal slotmapreduceInt32Arrayroute53typeerrorrfc4122l10neveryequalsetImmediateloggernegative zerojshintindicatorhasOwnPropertypropertiescorejapaneseastString.prototype.matchAllprotocol-buffersecmascriptESnextmodulesthroatES2015installerforEachrm -frreplayjsdomflagsArray.prototype.flattenwalkingECMAScript 7signalsObject.fromEntriesupbcryptescapespinnerhooksreact-hook-formdirectoryinspectguidparsefromes2018rm -rfaccessorRegExp#flagscurlargumentloadbalancingutil.inspectregular expressionstypanionlinuxbrowsermkdirscall-boundemrRFC-6455libphonenumberpicomatchmobileievaluespruneerror-handlingRxsyntaxerrorinferenceeslintplugindategradients cssdotenvqsxhrcloudtrailstreamstreams2Object.entriesvarsmochaSettrimxdg-opengetoptReactiveXfps.envfind-updeepcopystreams-0stablezeroregular expressionjsestypescriptexpressreadableparsingstartershampackagewritablestyleguidedropvisualtraversehttpsetPrototypeOfpathgetbrowserlistoptimizersequencereal-timebundlingflateventEmitterhardlinkscommand-linewriteMicrosoftes7css variablebundlerdeep-clonejwtismiddlewarees2015sinatradeletearraybufferArrayBuffercolourredactlogmatchespackage managerlengtheventswarningtaphookformcharacterArrayarttypepropcolumnSymbol.toStringTagreduxcloudwatch__proto__bytequerystringencryptionavaexecperformanceURLSearchParamscommandstylesjestxdgless cssstartspeedtsString.prototype.trimhandlersmacosrgbdeepphonewidthaccessibilitypnpm9lruStyleSheetapiCSSconcatdefaultES2022formkoreanreuseECMAScript 6testiteratorassertionrdsa11ysuperagentnested csswordwrapkeyWebSocketcolumnscheckcall-bindelbRegExp.prototype.flagsunicodepositivecorscss-in-jsyupworkspace:*YAMLcolorses-shimsbindexecutableES6joifsfastifymixinssimpledbsymboltc39arrayBigUint64Arraymkdirkeys[[Prototype]]TypeBoxfullJSON-SchemafluxECMAScript 2021Streamssettingssqsless compilerwaittimeimmerxtermsymlinkslastqueueMicrotaskrmdircomputed-typescircularmulti-packageES7awesomesaucepreserve-symlinksfigletmetadataObject.valueschromiumttyspawnuuidexpressionless.jshashObject.assignplugindeep-copybootstrap lessdomawaitcollection.es6parentsgroupbusylistenersfetchWeakMapcoerciblehigher-ordermoverestmatchAllserializerformattingmoduleserializegradients css3cssjavascriptFloat64Arrayoffsetstylewatchzodtoolsinternaljsonpathtypedarraynopeboundelmkarmastringpackagesfunctionglobalsspecthrottlehas-ownregexstylingiterationconcatMapES5descriptionObservablepreprocessorarraysJSONcomparepostcssratesideenderTypedArraymimetoobjectformatidprivate data_.extendtestercodescachebyteOffsetcryptovalidateECMAScript 2018@@toStringTagArrayBuffer#slicefastcopyextrapropertyArray.prototype.containsfindLastIndexstdlibjsdiffreadablestreamArrayBuffer.prototype.slicegenericsargparsewordbreakcommandertextfindupfast-deep-copyclassnamebuffersisConcatSpreadableiamasciielasticacheentriesgetPrototypeOfendpointvalueconsoletrimLeftworkflowwatchercreateECMAScript 2023serializationnativestructuredCloneES2020ReactiveExtensionsfolderObject.keyschaidefinePropertyHyBisigtermsymbolscloudformationoperating-systemprivatenodeslicejasminereducerdescriptorsopenerajaxfile systemdirshimRxJSsymlinklimitbrowserslistfull-widthmomentlooktypeslintrouterECMAScript 2022sharedponyfillomitObservablesUint8ClampedArraysuperstructfunctionsES2017react-testing-libraryBigInt64Arrayperformantfastoutputsignalwgetrequestbootstrap csschildclassesglacierpatchec2awsoptimistbeanstalkvpctrimEndECMAScript 2017reactlimitedlook-upprettyfast-deep-cloneshrinkwraptslibtrimStartlessrmdom-testing-libraryexit-codeFunction.prototype.namevariablessetECMAScript 2019utilitycallbindargumentssearchjsxtoSortedglobalimportfindtermmakepyyamlauthenvironmentfindLastchineseObjectes2016amazonscheme-validationdefinemonorepotypeofchromebyteLengthquoteconnectmatchIteratorassertcss lesslinewrapdebugreducedependenciescjkpredictablecallboundhotvalidationvestcloudsearchwafloadingpromisesomeansitaskconfiginterruptsstatuspipetrimRightexemrustatecloudfrontarktypegetOwnPropertyDescriptorES2023restfulargsformsi18nlauncheditorclass-validatorefficientweaksetintrinsicwhatwgcollectionappgdprutildataViewenvironmentsrandom
1.0.0

1 year ago