1.0.19 • Published 1 year ago

@hishprorg/deserunt-et v1.0.19

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

@hishprorg/deserunt-et 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('@hishprorg/deserunt-et');

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

harmonyupobjWebSocketequalitytestcommandconcatcolorsTypeScriptvestnumbereffect-tssomeglacierec2eventDispatcherReflect.getPrototypeOfisConcatSpreadablepopmotionstringifygraphqltoSortedmkdirpminimalowncss-in-jscachedebugfantasy-landES3shebanginferenceprocesscharactersvaluefunctionalgetterObservableslotArrayBuffer#sliceObject.getPrototypeOfajvparentsqsECMAScript 3cssfnmatchhardlinksassertdomURLfsregexfullwidthextendStreampackage.jsoninfindLastes5optimizertddclassnamesgetxmlapppipeprunecomparesharedexecfilestylingcloudformationpackagesdependencieslanguagedeepcloneperformantiteratorESextraInt16ArrayserializerflagscensorRegExp#flagswaf__proto__polyfill_.extendtransformboundreact posepropertyvpcSymbol.toStringTagES2022uninstallemojireadtypesafefront-endString.prototype.matchAllhelperecmascriptinstallerelasticachereadabletoReversedmrumake dircjkautoscalingnamesloadbalancingzxweakmaptestingmoduleconsoleimmersortedsyntaxbundlerhandlerkarmafeedloggerArray.prototype.flatwhichBigUint64ArraybinariesUint32ArraykinesisreducerignorehelpersdiffESnextsetPrototypeOfutil.inspecttelephoneieroute53wgetjavascriptdataviewFloat32Arraycolumnssideregexpthreepatchproxyvisualworkerpositivestyled-componentsback-endArray.prototype.containstraversesafeidletypesrmscheme-validationES8descriptortypechromiumworkflowrgbterminalendpointRFC-6455globaljsonschemafrombrowserwalkingtypedarrayssetterwebxtermYAMLserviceES2015cloudwatchrfc4122argvspeedclassesasyncURLSearchParamspicomatchpreprocessorshellmoduleses6fast-deep-copyqueuefastramdaincludespostcss-plugintypedcolorCSSStyleDeclarationsharedarraybufferclonemanipulationeslintrm -rfgitignoreawesomesaucechannelgetintrinsicjasmineinternal slotsettingsmaprequireargsxhrspinnersreadablestreamObject.entriesvaliddeepjson-schema-validationclassnamemomentIteratorinspectgenericsarrayECMAScript 2016server@@toStringTagcoloursesquotematchshimpromiseFloat64Arraytacitasciideep-cloneisponyfilldefinePropertyObject.fromEntriesprivate dataworkspace:*[[Prototype]]widthprefixefficientpoint-freereact-testing-libraryformscolumnnegativeinstallschemeexecObjectoffsetRegExp.prototype.flagseverymockresolveaccessoryupbytehigher-ordermapreducematchAllwarningJSON-Schemaobjectschemarm -frnodepurecall-boundtypescriptshambabeldescriptorsdeletestreamremove
1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago