1.1.14 • Published 3 days ago

@hishprorg/deserunt-sequi-ex v1.1.14

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

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

util.inspectobjcallbindlimitedReflect.getPrototypeOfpropertiesvalidateFloat32Arrayvisualconvert-00es2017real-timelintArray.prototype.flatMappackage.jsonopeners3parentlinkrapidObject.ismapreducepipeexpressioncopyregexpsetcloudtrailendpointtypesES2023checksymlinksFunction.prototype.namebuffersprivate datadirpatchcharsetextraES8findLastdeep-clonesuperagentfastkarmareducesetPrototypeOfcall-bindspringprotowritemkdirsObject.valueslengthparsegroupcontainsregularmkdirpRxprotocol-buffersponyfillreact-hookswafInt16ArrayescapejsxArrayBuffer#sliceBigUint64ArraysnsdeepcopyzodSymbol.toStringTagfigletexecutablesharedgenericsredux-toolkitbeanstalkes-abstractuninstallbundlerjshinttapECMAScript 7streams2espreefindupcolorvalidationgetoptcollectionchineseassertclass-validatoreslintconfigbannerrequireaccessorgesturesES2015arktypeUint8ClampedArraytypescriptphoneperformanceReactiveXoffsetmodulefindLastIndexttytouchomitdatastructuredescriptionserializerYAMLcalltyped arraymatchAllformatpropertyinkeyglobsafetypaniontextdiffappbddJSONstoragegatewayfunction.lengthUnderscoreawscolorsecmascriptsameValueZeroelbdraghashes6telephonechromiumcacheFloat64ArrayidentifierscolumnrequestUint32Arraynopei18nhigher-orderchaibrowserstreamworkspace:*simpledbtaskexeratelimitPushdayjsstreamsTypeBoxcharacterCSSStyleDeclarationString.prototype.trimreact-hook-formchromegetPrototypeOfhttpsSymbolHyBishambrowserliststringifyECMAScript 2018bindpersistentpicomatchregular expressionthroatworkerpackagestypedarraysgetzerormdirenderlibphonenumberreadablestreamtypedarrayArrayBuffer.prototype.sliceinternalarraysECMAScript 2023structuredCloneArrayBufferairbnbrm -rffoldercryptodescriptorcode pointsarraybufferlookchannelresolvecore-jsnativebusyroute53sequencetypeoftypeerrorWebSocketdropqueueECMAScript 2016popmotioneast-asian-widthReactiveExtensionsemrinternal slotjstostringtagsortuppostcssStreamsstringifiermonorepoicubyteOffsetcharactersbytetoolsasyncpostcss-plugintrimStartcollection.es6function.envECMAScript 2015styled-componentspluginglacierlrurateRegExp.prototype.flagsyuploggingformInt32Arraylockfilefind-upECMAScript 2019tslibbundlingcolumnsutilitycallboundwebfast-clonehookformconsolelocationcomparees-shimsurlsextensionvalidtypedformattinglanguagelaunchinstallprotobufform-validationeditorconsumeuuidarraysymlinkdefinePropertysqsECMAScript 2021settingsdom-testing-libraryprettyperformantMicrosoftjsdomObjectfpsdefineprefixajaxwidthwalkingframerregexestreepushescall-boundmove_.extendAsyncIteratorinferenceECMAScript 5utilitiescurloptimizergraphqlcommanderjasminestylingoptionStyleSheetECMAScript 3tsstart__proto__whatwgwebsiteviewcliextendurltraverseArray.prototype.findLastIndexflattenfunctionalmrucolourl10nES2018testingcss-in-jsdeepremoveobjectpruneString.prototype.matchAllsyntaxtoStringTagTypeScriptconcatjsonsetImmediateBigInt64Arrayfast-copyRFC-6455styledeterministicforEach256workflowdeepclonesliceieinvariantentriesajveslint-pluginenvironmentsECMAScript 2022MapArray.prototype.findLastvarsflatlimitpromiseparserspawnreadrecursiveschemerangeerrorapieslintpluginArrayfastclonebluebirdmatchfullwidthnodeconcurrencypackage managereslintassertionflatMapnodejsreducerxtermfixed-widthtermenvpackagekeyswalkES5hookstestreactqsspecserializeefficientargvelectronrfc4122shebangtrimEndjsonpathdomes2015RegExp#flagsemojiloadingfastcopytester
1.1.14

3 days ago

1.1.12

5 days ago

1.1.11

6 days ago

1.1.10

7 days ago

1.1.13

4 days ago

1.1.9

8 days ago

1.1.8

9 days ago

1.0.8

10 days ago

1.0.7

11 days ago

1.0.6

12 days ago

1.0.5

13 days ago

1.0.4

14 days ago

1.0.3

15 days ago

1.0.2

16 days ago

1.0.1

17 days ago