4.10.93 • Published 10 months ago

@diotoborg/ab-facere v4.10.93

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@diotoborg/ab-facere 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('@diotoborg/ab-facere');
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

quoteFloat32Array$.extendmergemovevalueObject.definePropertyespreefullpipefile systemmkdirpcss nestinges5ECMAScript 7tsslicetoStringTagec2core-jsintrinsicperformantoptimistsetImmediateschemalogginges2016gradients csstypedarrayindicatorspinnersArrayserializationlinkECMAScript 2017s3uninstallformless mixinstranspilertypesjsRFC-6455getregular expressionimmutableeventDispatchergraphqlkoreanzerotestingwaferror-handlingfast-deep-copytypeofforEacharraybufferpromiseSetes8writehashObject.keysArray.prototype.flattenarktypetimeES2018directoryHyBienvironmentspackagestoobjectvalidateequalityfast-copynegative zerogetintrinsicxhrstableshebangfast-clonepushstyled-componentsnpmignoreacornclass-validatortranspilecliletfetchrapidi18ndescriptionhandlersvariables in cssutilityprototypetrimprotostylingreadtermpostcss-plugineffect-tsbinstylesheetswfbabelpackage.jsondescriptorcreatedependency managerstructuredClonemapreducequerystringweaksetArray.prototype.findLastIndexspawnjoiStreamenvregular-expressionsymbolReflect.getPrototypeOfRxbrowserlisttrimStartpicomatchpropertyinstallclassnamedatahas-ownsyntaxerrorframerPromiseObject.iseveryprocesstypecss lessES8String.prototype.trimlistenersecmascriptWebSocketsl10nECMAScript 5symlinksesmixinsmanagerpathauthloadingtoArraytouchflatgenericscomputed-typesESnextebsWeakSetopensslpopmotionECMAScript 2023Array.prototype.includesES5flagsinternalenderECMAScript 2022bindutilES2017exit-codefunctional3dmapstringifyreact poseObjecthardlinkspackage managervaluesIteratoramazonES3channelUint8ClampedArraycompilerfantasy-landclassesbundlingmakeURLSearchParamsfunction.lengthtyped arraysuperstructbootstrap cssglobal this valueSymbolposereuseObject.getPrototypeOfes-shimsflattensafetraverseUint32Arraythreesettermulti-packageyupphonestatusshammkdirnested cssfilecallboundapirecursivebuffersbinarypolyfillzodeast-asian-widthurlFunction.prototype.namenodeTypedArrayjson-schema-validatorenumerablees6ECMAScript 2018xtermredux-toolkitSystem.globaltypedES2023importstatelessless compilercss-in-jsbyteOffsetcolorschemetypanionlastCSSStyleDeclarationio-tstoolkitjavascriptiteratorformatreal-timeinferencetrimRight.envirqimportexportairbnbjestsymlinksdraghttpsfixed-widthObject.fromEntriesdeepcopyharmonycircularawsincludescolorsomitECMAScript 2019efficientReactiveExtensionsglobalsString.prototype.matchAllramdakeychinesestarterlintrgbinputreact-componentflagpoint-freecurriedservicespeces-shim APIsharedfastforkformsdeep-copykinesishookformObject.valuescharactergetPrototypeOfawesomesauceidentifierscontainsECMAScript 2015extrajsdomterminalcryptpreserve-symlinkssqshasOwnPropertyuser-streamsunicoderedactjsxback-endReactiveXfromsignalshandlersuperagentcsspersistentcloudwatchspeedyamlsignedlruregularvarstylesexpressionCSSECMAScript 3queryauthenticationstoragegatewayArrayBuffer#sliceparsebeanstalkestreeclientconsumefront-endreact-hook-forma11yrangeerrorelasticache.gitignoreES2022resolvegitignoreisConcatSpreadablehigher-orderreact animationasyncinternal slottypeerrorBigInt64ArrayInt16ArrayroutingsettingsES6util.inspectexpressUint8ArraydiffiteratelivesameValueZeroInt32ArrayArrayBuffercoercibleparserexitglobargvvalidationArray.prototype.flatMapdomhttpassertionlinuxes2015objectajveslintplugines2017ESfastifyES2021stringarrayslogtddfastclonetrimLeftcss variablecallbackgradients css3chromeautoscalingcommandprogresstextStreamsprotobufFloat64Arrayfindextendjson-schema-validationdatastructureSymbol.toStringTagiecollection
4.10.93

10 months ago

4.10.92

10 months ago

4.10.91

10 months ago

4.10.90

10 months ago

3.10.90

10 months ago

3.10.89

10 months ago

3.10.88

10 months ago

3.10.87

10 months ago

3.10.86

10 months ago

3.10.85

10 months ago

3.10.84

10 months ago

3.10.83

10 months ago

3.10.82

10 months ago

3.10.81

11 months ago

3.9.81

11 months ago

3.9.80

11 months ago

3.9.79

11 months ago

3.9.78

11 months ago

3.9.77

11 months ago

3.9.76

11 months ago

3.9.75

11 months ago

3.9.74

11 months ago

3.9.73

11 months ago

3.9.72

11 months ago

3.9.71

11 months ago

3.9.70

11 months ago

3.9.69

11 months ago

3.9.68

11 months ago

3.9.67

11 months ago

3.9.66

11 months ago

3.9.65

11 months ago

3.9.64

11 months ago

3.9.63

11 months ago

3.9.62

11 months ago

3.9.61

11 months ago

3.9.60

11 months ago

3.9.59

11 months ago

3.8.59

11 months ago

3.7.59

11 months ago

3.6.59

11 months ago

3.6.58

11 months ago

3.6.57

11 months ago

3.6.56

11 months ago

3.6.55

12 months ago

3.6.54

12 months ago

3.5.54

12 months ago

3.5.53

12 months ago

3.5.52

12 months ago

3.5.51

12 months ago

3.4.51

12 months ago

3.4.50

12 months ago

3.4.49

12 months ago

3.4.48

12 months ago

3.4.47

12 months ago

3.4.46

12 months ago

3.4.45

12 months ago

3.4.44

12 months ago

3.4.43

12 months ago

3.4.42

12 months ago

3.4.41

12 months ago

3.4.40

12 months ago

3.4.39

12 months ago

3.4.38

12 months ago

3.4.37

1 year ago

3.4.36

1 year ago

2.4.36

1 year ago

2.4.35

1 year ago

2.4.34

1 year ago

2.4.33

1 year ago

2.4.32

1 year ago

2.4.31

1 year ago

2.3.31

1 year ago

2.3.30

1 year ago

2.3.29

1 year ago

2.3.28

1 year ago

2.2.28

1 year ago

2.2.27

1 year ago

2.2.26

1 year ago

2.2.25

1 year ago

2.2.24

1 year ago

2.2.23

1 year ago

1.2.23

1 year ago

1.2.22

1 year ago

1.1.22

1 year ago

1.1.21

1 year ago

1.1.20

1 year ago

1.1.19

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.1.16

1 year ago

1.1.15

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