1.0.0 • Published 12 days ago

@landmineaknpm/doloribus-ad-consequatur v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 days ago

@landmineaknpm/doloribus-ad-consequatur Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

ES2020 spec-compliant shim for String.prototype.matchAll. Invoke its "shim" method to shim String.prototype.matchAll if it is unavailable or noncompliant.

This package implements the es-shim API interface. It works in an ES3-supported environment, and complies with the spec.

Most common usage:

const assert = require('assert');
const matchAll = require('@landmineaknpm/doloribus-ad-consequatur');

const str = 'aabc';
const nonRegexStr = 'ab';
const globalRegex = /[ac]/g;
const nonGlobalRegex = /[bc]/i;

// non-regex arguments are coerced into a global regex
assert.deepEqual(
	[...matchAll(str, nonRegexStr)],
	[...matchAll(str, new RegExp(nonRegexStr, 'g'))]
);

assert.deepEqual([...matchAll(str, globalRegex)], [
	Object.assign(['a'], { index: 0, input: str, groups: undefined }),
	Object.assign(['a'], { index: 1, input: str, groups: undefined }),
	Object.assign(['c'], { index: 3, input: str, groups: undefined }),
]);

assert.throws(() => matchAll(str, nonGlobalRegex)); // non-global regexes throw

matchAll.shim(); // will be a no-op if not needed

// non-regex arguments are coerced into a global regex
assert.deepEqual(
	[...str.matchAll(nonRegexStr)],
	[...str.matchAll(new RegExp(nonRegexStr, 'g'))]
);

assert.deepEqual([...str.matchAll(globalRegex)], [
	Object.assign(['a'], { index: 0, input: str, groups: undefined }),
	Object.assign(['a'], { index: 1, input: str, groups: undefined }),
	Object.assign(['c'], { index: 3, input: str, groups: undefined }),
]);

assert.throws(() => matchAll(str, nonGlobalRegex)); // non-global regexes throw

Tests

Simply clone the repo, npm install, and run npm test

take3dbuffersmimetypesArrayBuffer#sliceECMAScript 2016utilitiessanitizetestforEachanimationbrowserslistarktypesequencefileexpressprivateESshebangtrimStartframerguidfindLastfullwarningprotocol-buffersES2015watchdeepcopyansifind-uplinuxUint32Arrayes-shim APIoptimistuninstallstarterprettydefaultstatelesscommand-linenodejswatchingintrinsicartmime-dbtranspile0namehooksInt32Arrayes6serializesharedarraybufferstyleguidejsdiffESnextnested cssIteratorform-validationjQueryWeakSeterrorcss nestingauthES2017popmotioneventEmitterhashoptiondatautilcss-in-jsspawnextensioninspectdescriptorsArray.prototype.flatcompile lessbluebirdReactiveXUint8ClampedArrayjson-schema-validationupredux-toolkitdeep-clonemodulesglobinputxtermrobustworkspace:*@@toStringTagharmonyquotebcryptgroupmruassertsentriesreduxfast-deep-clonepyyamlpostcss-plugintimedom-testing-library[[Prototype]]loadingzeroajvStreamsunicodegetformatstreams2validationMicrosoftsyntaxstreamtypanionfolderlaunchless compileri18nisConcatSpreadablefantasy-landtrimEndavavalides7ES2023deterministiccomputed-typesregexplibphonenumbercolumnsgraphqlqueuereactgdprObservablemetadatarapidopenses2015lockfileformattingSetbddlistenersxdg-openlog_.extendpasswordObject.definePropertyextendratelimititeratores5pnpm9argumentCSSECMAScript 6frameworkmixins$.extendreact animationfullwidthSymbol.toStringTagflagsmapkoreanindicatorcurriedpromisefprm -frES2022dependency managerPromise-0sameValueZeroes-abstractpathnodebanneriecopytypedES2021util.inspectwatcherECMAScript 5preprocessorpersistentreal-timeclass-validatormatchclonefile systemlessrandomprototypetraverseauthenticationvara11ybabelruntimewaapiestacitslottypeofconcaterror-handlingpackagesawaitchromehasstylesafespringcheckObject.keyslinewrappolyfillassertionoffsetbundlerES2016invariantstylesArray.prototype.findLastECMAScript 2015internalcolormonoreporangeerrormakeECMAScript 2020threetypesafelastes-shimsObject.getPrototypeOfutilsaccessibilitydirjsdomjsonwatchFilereact-hooksdataviewrfc4122symlinksobjectdatastructureStyleSheetconstcss lessdescriptorsigintlanguagenegativeECMAScript 2018symbolsortweakmapcrypttoobjectreadablestreamObject.iseditorutilitycontainscircularsomemiddlewarestartarraysignaltesterArrayBuffergetPrototypeOfchaisettingsuuidreact posetsexecutablethroatregular expressionmomentECMAScript 2021compareArray.prototype.includeseslintfswebsitewidthincludesiterationconnecttrimLeftsetStreamObject.valuesRegExp.prototype.flagsrm -rfRegExp#flagscore-jslinkhasOwnbrowserschemesuperagentparse6to5es2018eslintpluginstringifyargves2017childcall-boundtypescriptkeysYAMLmkdirsidlewalking256accessorurlassigncsshttpsdraggradients css3figletairbnbjson-schemaarraybufferfunctionparentTypeScripttapebabel-corelimitpackage.jsoncjkl10nscheme-validationconcatMappropertiesinterruptsObject.assigndeletesharedtouchHyBispeedsymlinkInt8ArrayWeakMaptostringtagduplexvisualwordwrapquerystringjsonpathbindoncebatchtypesstablecorswgetArrayencryptioncolourRFC-6455fastifyassertstringifiervestgroupBytoSortedInt16ArraysigtermapollocoercibleeventDispatcherlengthappreadablefunctionscacheperformancepluginpositiveURLgettersignalsmodulexhrRxbundlingregexhookforminstallerjasminefull-widthperformantcollection.es6react-hook-formbyteLengthdropsyntaxerrorUnderscoredomJSONissanitizationdotenvserializerelectronomitlintArray.prototype.flattenmimegenericschannelbytergbinstallestreeES3bootstrap csstelephoneresolvegesturesviewconfigurablerequireTypeBoxprotoposechromiumweaksetminimalsetImmediatecallnpmefficientless csseslint-pluginflagrateeventsjwtString.prototype.trimArray.prototype.findLastIndexflatMapWebSocketstoArrayclientvalidateecmascriptasyncPushjsxfunctionaloperating-systemhelperssetterReactiveExtensionsvariables in cssgetOwnPropertyDescriptorshimstyled-componentswebtypedarrayparsercmdlesscssreduceterminaltc39collectionloggerArray.prototype.filterajaxmake dirflatUint16ArrayextraqueueMicrotaskstructuredClonespinnerscode pointsdebugmochadayjsjapaneseoutputfindupfetchsetPrototypeOfnumberxssspinnerBigUint64ArrayprogresscallbackTypedArrayvariablespackage managertaskemitexit-codeECMAScript 2017exekeyconfigwhichbusycommanderrecursivepipecodeszodsearchawesomesaucetoolsredactfindLastIndexstringfastcloneObservablessliceECMAScript 2023flattenBigInt64Arrayexecschemaapifixed-widthSymbolqsdeepES2020equalitysuperstructhardlinksstylingrmES2019consumecharacterhttpponyfillcommandbreakinternal slotsideloggingprefixexitshrinkwrapreadirqjsonschemawhatwgdeep-copyformxdgtestingpurespecnamesescapenativeletpostcssttyArray.prototype.containsfast-clonenopestreamsclassesurlstranspilerprivate datapicomatchJSON-SchemaECMAScript 7argparsecryptotslibmergedateyupObjectlook-upthrottlebootstrap lessES7joiObject.fromEntriesshamequalcompilerpreserve-symlinkssymbolsjestCSSStyleDeclarationenvironmentramdamobileclassnameless.jswritablegetoptwindowsyamlbounddirectoryexpressionclistylesheetcensorUint8ArraypropprocessenumerabletdddefinegetintrinsicReflect.getPrototypeOftextprotobufcurlwrapwordbreakECMAScript 2019requestURLSearchParamsargumentsopenerWebSocketpoint-freepruneenderdefinePropertypackageFunction.prototype.namehigher-ordermovebrowserlistphonegradients csstoolkitcolumnkarmauser-streamsbufferopennegative zerowaitmacospromisesimmutablecolorstypeerrorobjfseventses2016classnamesstatusmkdircallboundwritejson-schema-validatoroptimizerimportshellfastcopymkdirpworkervalidatorES6east-asian-widthcharacterscoreformspatchtapMap.envtermastcall-binddebuggereveryRxJScss variableiteratematchestypedarraysfast-copy
1.0.0

12 days ago