1.4.33 • Published 1 year ago

@hishprorg/deserunt-sequi-ex v1.4.33

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year 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.3.31

1 year ago

1.3.32

1 year ago

1.2.24

1 year ago

1.3.33

1 year ago

1.2.27

1 year ago

1.1.16

1 year ago

1.2.28

1 year ago

1.1.15

1 year ago

1.2.25

1 year ago

1.2.26

1 year ago

1.1.19

1 year ago

1.2.29

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.2.30

1 year ago

1.2.31

1 year ago

1.4.33

1 year ago

1.1.23

1 year ago

1.1.22

1 year ago

1.1.21

1 year ago

1.1.20

1 year ago

1.1.24

1 year ago

1.1.14

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.13

1 year ago

1.1.9

1 year ago

1.1.8

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