1.0.0 • Published 1 year ago

@wemnyelezxnpm/veniam-saepe-aliquid v1.0.0

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

@wemnyelezxnpm/veniam-saepe-aliquid 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('@wemnyelezxnpm/veniam-saepe-aliquid');

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

iskeysdeleteminimalmatchesCSSmatchcall-bindexitthroatfoldermodulesdeepclonefast-deep-clonestatusdropjson-schemafull-widthfile systemtypesFloat32ArrayBigUint64ArrayqsjsonarktypeinstallerjsdomUint8ArrayjQueryframercsscolumndeep-copySymbolReactiveExtensionsWeakMapwatchingpreprocessorcommanderSymbol.toStringTagArray.prototype.filtermonorepodependenciesES2022cryptastreal-timebindequalityObservableECMAScript 7promisevaluedebuggerES2021ArrayBuffersiginttypesaferuntimecontainsonceES2018WebSocket256ttyArray.prototype.flattenclassesasyncwebeventDispatcherfilterReactiveXtoobjectbluebirddragprivatereduceUint8ClampedArrayassertajaxformURLSearchParamsES2015workerstringify0joiPromiseeswatchersanitizehooksArraytacitinternal slotpropRegExp.prototype.flagsexpressprivate dataansiawaitFunction.prototype.namelastcloneObject.definePropertytouchmime-dbwordwrapObject.valuesuser-streamslimitcompile lessdatermdirzodpushdeepspeedfigletpruneworkspace:*autoprefixerviewwalkyupURLconstUnderscoreFloat64ArraychromiumES5getOwnPropertyDescriptor.envauthclientfunctionalbundlingtypees-shimschaideepcopyfrompackage managermomentstatelesssymbolsi18nartfullarraysreact animationsymboltoolsconsoletrimRightES8hookformspinnersinspectremovedirectorydayjsapollokoreanlimitedstreamsmakeimmergroupnumberdataviewcodesECMAScript 2020telephoneenderlruIteratormatchAllless mixinsbootstrap cssgradients cssdescriptionES2017eslintconfigsequenceregexjscommandthrottlelanguageconfigES2020consumereactauthenticationvarimportnested csspostcsssideobjpostcss-pluginsyntaxerrorfileintrinsicsigtermes2015extracharacterdeep-cloneletconnectpackagesbundlergetPrototypeOfUint16ArraywatchasciiBigInt64Arraylintpackage.jsonbcryptYAMLa11yanimationgradients css3PushduplexprotobufES3ES6argvshamhelpersArray.prototype.flatMapsignalloggingjsonschemavaluesmkdirsinferencecode pointsextendgetintrinsicfastifytoolkitObject.entriesmoveexit-codeentriesJSONiteratees-shim APIcommand-lineclass-validatorerror-handlingless.jstoArrayvariables in csscoreReflect.getPrototypeOfincludesprogresssettersanitizationeast-asian-widthmake diroffsetes7mochatrimEndindicatorbreakreusefastclonefixed-widthlogstylesMappropertydirclassnamechineseloadingphonekarmaeverymulti-packageTypedArrayhigher-ordertranspilertddES7_.extendcss-in-jsfsmaptoSortedcolorsstyleECMAScript 5installutil.inspectInt16ArraytypeerrorconcatMapdotenvRxJSparentsortedpackagestdlibes5urlpnpm9stylesheetbddsort
1.0.0

1 year ago