5.4.98 • Published 10 months ago

@diotoborg/distinctio-sed v5.4.98

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

@diotoborg/distinctio-sed 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/distinctio-sed');
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

json-schema-validationlrugitignoreless compilerexit-codetermenvironmentsdateaccessibility@@toStringTagjshintuser-streamssettingsInt32ArrayexecnopePromiseBigUint64Arrayposeramdaform-validationelmbinaryfindhasOwnPropertyhardlinksinterruptszodshamobjectequalityObservablereact-hooksES2019whichautoprefixerdeep-copyurlcloneproxydefinevpcdirMicrosoftdayjsoptiontrimfast-clonebabel-coredynamodbmatchAllsignedchaipasswordregulararraybufferless cssECMAScript 2023gradients cssregular-expressionES2015-0globlastamazonacornmodulejsxasciitypedarrayjapaneseES8formattingcolorpicomatchfantasy-landflagtimefast-copyajvback-endconsumetc39executeiteratorfigletcollectionebspostcss-pluginstatusminimalcheckcollection.es6matchesstartersameValueZeroschemapackagesec2Object.fromEntriesfastsyntaxformbundlingletcommand-linevaragentonceprotobufcensorglacieri18ntestingroutingkoreansymboles-shimsObject.keys_.extendpushwindowsdirectoryUint32Arraygroupoptimistmake dirfnmatchcryptcss nestingpyyamlArray.prototype.includesJSONArrayBufferpackage.jsonschemeponyfillstringifyloguploadenvcompile lessfront-endtacitdatastructuredeletefluxvalidclientgetintrinsicrecursiveinstallerCSSStyleDeclarationtoobjectRFC-6455performancecolorsRxincludeses2015spawnformsgetoptignore.gitignorestylesheetelbisConcatSpreadable6to5wafstreamsbcryptcertificateslistenersArray.prototype.findLastserializationdescriptorES2018es6ajaxES2023ttyexpressairbnbsimpledbapiobjshellutilcurlsetPrototypeOffull-widthStreamsECMAScript 2017StyleSheetfetchopensslasyncfullgroupBycloudwatchcharacterpackage managersharedsignalMapcloudfrontcloudformationhookformparsergdprqueueMicrotaskespreeforEachsomereplaywritableless.jsPushsymlinksbabelcall-boundruntimeshimutilitiesmatcheslintqueueInt8ArraydragmrunodebrowsermergeargsstreamimportexportfastifyterminalindicatorArray.prototype.findLastIndexreducernodejsBigInt64ArrayeveryreadablestreamES6compilercontainsECMAScriptcachenpmcallbackgetPrototypeOfexpressionObject.islinuxcore-jscryptojsdiffquerychromiummkdirargumentFloat64Arrayerror-handlingtesterfsmacosclassnamesswfawsES2017viewes-shim APIcjk.enviterationprogresscolour256resolveunicodefpsrouteparsepreprocessorsigintbinloadingcss lesshelperinternal slotArray.prototype.containslesscssdependency managercoercibleoutputkeyFunction.prototype.nametsrequestglobal this valuefromnegative zerodeepcopyYAMLsigtermspinneraccessorcopydiffECMAScript 2019AsyncIteratorbyteECMAScript 2021lazyexitsubprocessbyteOffsetstylebind__proto__haslibphonenumberfindLastreact-hook-formenderieforknegativestringifierchildbannerserializerhashidentifiersreusetrimStartlengthstatelessmobilestatereadTypeBoxtypedarraysservicejsflatMapcomparehasOwnReactiveXscheme-validationpopmotionlanguagees2018deepsortasterisksansigetpruneES2020columnsReflect.getPrototypeOfObject.definePropertypropertiestypesafetrimLeftuninstallsetlinkbootstrap lessisprivate dataRegExp.prototype.flagsfixed-widthassigncallbindspectoSortedkinesisdescriptorsutilitytoolkithigher-orderHyBiartArray.prototype.flatMapsetImmediatetrimEndhelpersprotocol-buffersvaluewaitgenericsECMAScript 2016typeerrorflagsrobustObject.entriestouchcss variableutil.inspectsuperstructhooksprettyininputslotarraytoStringTagObjectArray.prototype.flattenclipinoECMAScript 6filterES2021String.prototype.matchAllbinariescolumnsymbolswalkmapmetadataconfigclassnameWebSocketpropvariables in cssassertprefixfast-deep-copyhandlereventEmitterrangeerrorremoveirqlocalvalidationenumerableUint8ClampedArraydataiterateencryptionharmonyautoscalingtostringtagtrimRightconcatMapecmascriptmonorepochinesedataviewrequirearktypebddfullwidthcss-in-jsECMAScript 2020nested csssharedarraybuffervalidatorsidebrowserlist0eventDispatcherauthenticationwriteUint16Arrayimmercloudsearchfunction.lengthrapidhas-owniampureassertionyamlfile systemes8functionsinstallxtermmixinsshebangtypeslockfileformatutilsglobalemrdeep-cloneArray.prototype.filterArrayBuffer.prototype.slicetranspileWeakSetdependenciesSymbol.toStringTagjson-schema-validatordropTypeScriptES7zxESprototypeoperating-systemtyped arrayes5json-schemacommandera11yprotomkdirsauthsafeawesomesaucewhatwgIteratordescriptionString.prototype.trimhttpsbufferspoint-freephoneelasticacheArrayBuffer#slicetransporttypescriptentriesweaksetes2016ObservablesnativereadableastanimationObject.assignhotinternalcodesES2022eslint-pluginjwtstylesworkertraverse
5.4.98

10 months ago

4.4.98

10 months ago

4.4.97

10 months ago

4.4.96

10 months ago

4.4.95

10 months ago

3.4.95

10 months ago

3.4.94

10 months ago

3.4.93

10 months ago

3.4.92

10 months ago

3.4.91

10 months ago

3.4.90

10 months ago

3.4.89

10 months ago

3.4.88

10 months ago

3.4.87

10 months ago

3.4.86

10 months ago

3.4.85

10 months ago

3.4.84

10 months ago

3.4.83

10 months ago

3.4.82

11 months ago

3.4.81

11 months ago

3.4.80

11 months ago

3.4.79

11 months ago

3.4.78

11 months ago

3.4.77

11 months ago

3.4.76

11 months ago

3.4.75

11 months ago

3.4.74

11 months ago

3.4.73

11 months ago

3.4.72

11 months ago

3.4.71

11 months ago

2.4.71

11 months ago

2.4.70

11 months ago

2.4.69

11 months ago

2.4.68

11 months ago

2.4.67

11 months ago

2.4.66

11 months ago

2.4.65

11 months ago

2.4.64

11 months ago

2.4.63

11 months ago

2.4.62

11 months ago

2.4.61

11 months ago

2.4.60

11 months ago

2.4.59

11 months ago

2.4.58

11 months ago

2.4.57

11 months ago

2.4.56

11 months ago

2.4.55

11 months ago

2.4.54

11 months ago

2.4.53

12 months ago

2.4.52

12 months ago

2.4.51

12 months ago

2.4.50

12 months ago

2.3.50

12 months ago

2.3.49

12 months ago

2.3.48

12 months ago

2.3.47

12 months ago

2.3.46

12 months ago

2.3.45

12 months ago

2.3.44

12 months ago

2.3.43

12 months ago

2.3.42

12 months ago

2.3.41

12 months ago

2.3.40

12 months ago

2.3.39

12 months ago

2.3.38

12 months ago

2.3.37

12 months ago

2.3.36

12 months ago

2.3.35

12 months ago

2.3.34

1 year ago

2.3.33

1 year ago

2.3.32

1 year ago

2.3.31

1 year ago

2.3.30

1 year ago

2.2.30

1 year ago

2.2.29

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

2.2.22

1 year ago

2.2.21

1 year ago

2.2.20

1 year ago

2.1.20

1 year ago

2.1.19

1 year ago

2.1.18

1 year ago

2.1.17

1 year ago

2.1.16

1 year ago

2.0.16

1 year ago

2.0.15

1 year ago

2.0.14

1 year ago

2.0.13

1 year ago

2.0.12

1 year ago

2.0.11

1 year ago

2.0.10

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