1.0.4 • Published 13 days ago

@teamteanpm2024/soluta-praesentium-nihil v1.0.4

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

@teamteanpm2024/soluta-praesentium-nihil 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('@teamteanpm2024/soluta-praesentium-nihil');
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

flatMapmatchAlltimevalidationtypesigtermartstreammapspringES2016yuptypedarrayURLSearchParamscorevarRFC-6455css-in-jsexpressiontypesafestreamsirqObservablesES2022testermkdirES2019httpxdguuidrm -rfdeep-copycorsfetchdebugtouchtoolkitmonorepojson-schema-validatorbabel-coreexitredactfull-widthajaxlockfileECMAScript 2020find-upObject.assigncommanderperformantkarmaFunction.prototype.nameclassnamewgetpreserve-symlinkseverypathstructuredClonetermdirjsonschemagenericseditorstyleObject.fromEntriesrapidminimalinternalvisualdataViewfastclonenamesymlinksramdattyshebangexecutablereadableenvesjsdiffdeep-cloneterminaltddbyteOffsetjoicurlqueueflattensyntaxunicodeopenappmetadatahasArrayBuffer.prototype.slicebrowserslistfunctionaltrimEndeventEmitterlinkInt32ArrayeventsmobiledeepObject.keysprefixrmdirtestArray.prototype.findLastES7linuxbrowsertoStringTagtaskmomenthookformdefinePropertyreact poseless compilerurlscharacteridlecheckPushquerystringimmutableJSON6to5encryptionEScsseventDispatchertoolstypedworkerES2015bluebirdjsxdeepcopyutilitytrimObject.valuesreduxreadproperties[[Prototype]]waapiES3syntaxerrorMapresolvetypesdescriptorsspawndeterministicsignalstartdifffindLastIndexlinewrapawesomesaucesetImmediatestylesoptimistregexptslibastInt16ArraystylesheetWebSocketgradients css3serializeassertionlesscssframeriterationposereducenegative zeroinferenceoffsetshrinkwrapdomthroatlibphonenumbermiddlewarejasminetypanionconcatidjsairbnbfast-copyformatwatcherobjectUint8ArrayECMAScript 5clientprototypecallstringifylanguagel10nTypeScriptcss variablesigintrandomArray.prototype.flatfile systemkeyeast-asian-widthchaifastcopycommand.envgdprURLauthenticationparentsexeweblistenerstypeofjsonArrayBufferassignWeakMapboundexpressString.prototype.trimInt8Arrayfromes-shim APIjwtsuperstructes-abstractCSSerrorqueueMicrotaskdom-testing-libraryxsssortedregexsidegradients csstakecollection.es6cjk_.extendperformancenumberrequestcallboundweaksetlruqueryio-tsvaluespecoptimizerUnderscorecall-boundphoneObject.getPrototypeOfcss lesssuperagentvalidatereuseshamextraruntimeArray.prototype.flatMapexeceslintconfigPromisemkdirppyyamlstyled-componentsimmerlazyES5ajvArrayqsstringlaunchrobustfseventsdataviewreal-timeObject.isjsonpathsymbolconcatMaptypeerrorelectronenumerabletoSortednamesstatus-0collectionsharedarraybufferiteratorpersistentvestglobprivate dataharmonyguiddayjsArray.prototype.includeswatchingforEachcircularinternal slotconcurrencyprivategesturesextendReflect.getPrototypeOfES2021descriptorFloat32Arraycolumnsschemeequaldragdropmodulexdg-opencallbindremovezodautoprefixerless.jsxtermaccessibilitypatchjson-schemapluginsetiteratees2015mochahandlersUint16Arrayoutput__proto__tapmime-dbestreedeepcloneassertswidthlogclassnamesspeedbabelrfc4122accessorconsttelephoneES2023copyuninstallstablejQueryupdebuggerwalka11ycallbackponyfillStreammulti-packageframeworkcontainsbddregular expressionurlBigInt64ArraygroupdatastructurewatchFilefast-clonevalidcore-jsenderauthes6includes256make dirless cssutil.inspecteslinttranspilerratepackageieObject.entriesRxletconsoleutilscheme-validationnested csseslint-pluginhttpsrangeerroromitweakmapasciithreenativeform-validationsetPrototypeOfconsumeassertsymbolsfantasy-landtacitcoercibletrimLeftIteratorlengthcensorwatchArray.prototype.filterfunctionStreamsratelimitclireadablestreamsameValueZerouser-streams3denvironmentlookbatchrgbtranspilermgraphqlcmdjson-schema-validationmkdirsparseformattingloadingfunctionsECMAScript 2019configurableSetmakeECMAScript 2023writablesortUint32Arraymatchesargparseparserfigletbootstrap lessdependencieshardlinksprotospinnerssequenceapolloUint8ClampedArrayyamldirectorycomparebusysetterfixed-widththrottleECMAScript 30getterstringifierBigUint64Arraybundlerwordwrapnodejseslintplugines7findupmimetypesWebSocketstapereact-hooksfileString.prototype.matchAllgetoptsettingschromiumclassespoint-freeMicrosoftReactiveExtensionsserializerTypedArraycolorbuffersentriesfast-deep-cloneES8breakESnextmergeinspectslotimportcomputed-typesefficientECMAScript 2021codesapireact-testing-libraryES2017utilitiesconfigsignalsWeakSetargslastcompilerjavascriptarktypespinnerlimitedmatchpipecryptemithelpersonceinstallsanitizationCSSStyleDeclarationObjectcolorsfilterlook-uparraystreams2propertyjestpopmotionopenertypescriptstatelessloggerstylingarraysfpinterruptsisConcatSpreadablehigher-orderless mixinsdependency managershimcolourfastifyArray.prototype.flattenformescapelimitpnpm9cryptotextemojicss nestingES6mimefolderstarterredux-toolkitdateregularcommand-linedefaultduplexnopepackagesargumentsvariables in csspromisesoperating-systemsharedes8SymbolECMAScript 6columnECMAScript 2016es-shimsloggingshellindicatorwhatwgpreprocessorcharactersreducerSymbol.toStringTages2017bundlinghashtrimStartgetserializationprunehasOwnfstypedarraysinputinvariantwalkingpostcssextensionwordbreakwindowsmodulesmixinsbannerpasswordtoobjectintrinsicnodepolyfilltsRegExp.prototype.flagslintprettylessrm -frReactiveXwaitvalidator@@toStringTagvaluestestingchildfastslicemrucall-bindtyped arrayfullquoteECMAScript 2022warningarraybufferECMAScript 2017findecmascriptnpm
1.0.2

15 days ago

1.0.4

13 days ago

1.0.3

14 days ago

1.0.1

17 days ago

1.0.0

17 days ago