2.1.10 • Published 5 days ago

@taktikorg/facilis-itaque-ut v2.1.10

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

@taktikorg/facilis-itaque-ut Version Badge

github actions coverage License Downloads

npm badge

Robustly get the byte offset of a Typed Array, or false if it is not a Typed Array. Works cross-realm, in every engine, even if the byteOffset property is overridden.

Example

var typedArrayByteOffset = require('@taktikorg/facilis-itaque-ut');
var assert = require('assert');

assert.equal(false, typedArrayByteOffset(undefined));
assert.equal(false, typedArrayByteOffset(null));
assert.equal(false, typedArrayByteOffset(false));
assert.equal(false, typedArrayByteOffset(true));
assert.equal(false, typedArrayByteOffset([]));
assert.equal(false, typedArrayByteOffset({}));
assert.equal(false, typedArrayByteOffset(/a/g));
assert.equal(false, typedArrayByteOffset(new RegExp('a', 'g')));
assert.equal(false, typedArrayByteOffset(new Date()));
assert.equal(false, typedArrayByteOffset(42));
assert.equal(false, typedArrayByteOffset(NaN));
assert.equal(false, typedArrayByteOffset(Infinity));
assert.equal(false, typedArrayByteOffset(new Number(42)));
assert.equal(false, typedArrayByteOffset('foo'));
assert.equal(false, typedArrayByteOffset(Object('foo')));
assert.equal(false, typedArrayByteOffset(function () {}));
assert.equal(false, typedArrayByteOffset(function* () {}));
assert.equal(false, typedArrayByteOffset(x => x * x));
assert.equal(false, typedArrayByteOffset([]));

const buffer = new ArrayBuffer(32);

assert.equal(8, typedArrayByteOffset(new Int8Array(buffer, 8)));
assert.equal(8, typedArrayByteOffset(new Uint8Array(buffer, 8)));
assert.equal(8, typedArrayByteOffset(new Uint8ClampedArray(buffer, 8)));
assert.equal(4, typedArrayByteOffset(new Int16Array(buffer, 4)));
assert.equal(4, typedArrayByteOffset(new Uint16Array(buffer, 4)));
assert.equal(8, typedArrayByteOffset(new Int32Array(buffer, 8)));
assert.equal(8, typedArrayByteOffset(new Uint32Array(buffer, 8)));
assert.equal(16, typedArrayByteOffset(new Float32Array(buffer, 16)));
assert.equal(16, typedArrayByteOffset(new Float64Array(buffer, 16)));
assert.equal(16, typedArrayByteOffset(new BigInt64Array(buffer, 16)));
assert.equal(16, typedArrayByteOffset(new BigUint64Array(buffer, 16)));

Tests

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

package managerrateboundreworkfsjoirm -rfcall-bindjseventEmitterroutingFloat64Arrayworkspace:*concatimportECMAScript 2020regexpeslintconfigvalueemitfixed-widthpatchfastclonehigher-orderasyncrfc4122toSortedhookformtrimEndInt32ArraycloudfrontbyteLengthunicodeguidautoprefixertypeswarningstdlibmochabddlocalgetintrinsicreact animationstablepackagesreact posenpmreact-hook-formrequirerangeerrorjsxlinewrapgesturesstylesgdprcolumnsiteratebrowserslistsimpledbsideUint32Arraystreams2ES6HyBipopmotionlruimmermakereact-testing-librarycomputed-typesart__proto__symbolvalueslookreactUnderscoregetPrototypeOfgetoptformattingtrimRightflatMapcallbackjavascriptreducerAsyncIteratortoolssafeieexecutecloudtrailbannerstructuredCloneESforkPromiseSymbol.toStringTagwebsiteisArray.prototype.flatwhichcorewordwrapredactcommandermkdirsfunction.lengthautoscalingproxyebsvpcES2016has-ownReflect.getPrototypeOfbufferswfObject.entrieswidthfastifyshamrm -frshebangfast-copydeterministicmkdirpcoercibleassertsdatastructurenodeWeakMaplocationhttpssuperagentterminalcore-jsstyled-componentswrapUint8ClampedArrayWebSocketsemrObservablespringdomgraphql-clientchaiArrayES2023ES2021timemomentECMAScript 5extendgetqueueMicrotaskes-abstractweakmaptypeddayjsttymonorepotesterprotobufbundlerextrasource mapincludestapeArray.prototype.flattenpreserve-symlinksdeepfastbinenvprototypetaskworkflowURLcurllook-up256sliceRegExp#flagsperformantansiCSSPushsearchfeedcryptoReactiveXsettingsregular expressiondotenvmkdirmake dirtypedarrays-0symlinksphonermdirdependenciesspecjasminepushmatchAllObject.assignsameValueZerojshintxmlefficientopenlogdefineawesomesauceapolloglobalsreal-timeprocessSetzoddropmoduletypeerroreventDispatchertypelimitfastcopyregularjestdynamodbrapid@@toStringTagsesstoragegatewayloggingstartereslint-plugineventstrimLeftbusy.enveast-asian-widthrobustjapanesesymlinkBigUint64ArraywritepersistentreadablestreamECMAScript 2023CSSStyleDeclaration0WeakSetoncedeletesomeec2outputindicatorponyfillObservablescomparehtmlfast-deep-clonequeryesrsspreprocessorRxtslibinspectspinnersdateWebSockettyped arrayprogressdefaultwordbreakappdependency managershrinkwrapTypedArrayArray.prototype.findLastkeydirectoryObjectqueuemergetraverseSymbolfindLastIndexcachetostringtagES8kinesisdom-testing-libraryflatinferencetrimbluebirdlockfileescaperedux-toolkitstreamintrinsicstringifyspeedlintes2016expressioncommandanimationObject.valuesatomcompilerfoldercopycharacternamereducetransformexethrottlecall-boundemojitsfast-deep-copydescriptionstringnumbermulti-packageargses2015$.extendfunctiondeepcopybreakecmascriptperformancecodesmovetapidledescriptorscloudsearchloadingURLSearchParamsratelimitastrandomBigInt64Arrayxdg-openkeysendertc39sortminimalUint16Arrayxhrloadbalancingwritablelanguageajvpathhttpwhatwgshellio-tstypeofnodejsString.prototype.matchAllfind-upeslintpluginiampostcssArray.prototype.flatMaphasglacierglobES3ECMAScript 2022drages2017chromiumcssarraymapbatchfilterassertionworkerhasOwnvalidECMAScript 2015testingFloat32ArraystylearraysrdskarmaReactiveExtensionscallbrowserbyteOffsetrgbkoreanStreamsequalMicrosoftframeridentifierszxflattenidisConcatSpreadablecontainsmatchresolvechineseimportexportutilconfigurablei18ntypescriptprotocol-buffersprivate dataECMAScript 2018promisereusespawnRegExp.prototype.flagsoffsetflagwafcircularawaiturlfunctionsrecursivevalidationinstalleres-shimses2018threesharedarraybufferobjcliobjectdataViewchannelawsinvariantoptimizerwaapiestreeformatnamesESnextES2015startsyntaxdeep-copyimmutableasciipipeomitjsdiffECMAScript 6helpergroupreadeslintstreamsfromtrimStartes6matchesposefpsamazonredirecttoobjectassigntoolkites-shim APIlinkviewes8sortedwgetmanipulationpackage.jsonsetconcurrencypositiveeditorgraphqlspinnernopediffargumentscollectionfindmobiletranspilerES5validateUint8Arraypromisescollection.es6qsoptimistruntimehookscolorsmapreducezeroairbnbclass-validatordirassertcloudwatchpolyfillxtermmruECMAScript 2016descriptoroptionstatelessdatas3jsones7_.extendYAMLECMAScript 2017limitedeveryfunctionalschematypanionflagsentriesES2019argvArrayBuffer#slicebinariesfile systemArrayBufferObject.fromEntriespnpm9generics
2.1.10

5 days ago

2.0.10

6 days ago

2.0.7

9 days ago

2.0.6

10 days ago

2.0.9

7 days ago

2.0.8

8 days ago

2.0.5

11 days ago

2.0.4

12 days ago

2.0.3

13 days ago

2.0.2

14 days ago

1.0.2

15 days ago

1.0.1

16 days ago

1.0.0

16 days ago