1.1.10 • Published 17 hours ago

@ellentorg/literate v1.1.10

Weekly downloads
-
License
MIT
Repository
github
Last release
17 hours ago

@ellentorg/literate 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('@ellentorg/literate');
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

accessorclassesArrayboundshamECMAScript 2021signalpatchconstmiddlewareduplexsharedhashstructuredClonewalkindicatorajaxiteratorpyyamlmakesyntaxerrorStyleSheeteventspackageio-tsswfeslint-pluginspringtouchforEachnegativeviewfile systemexitECMAScript 2022bootstrap lessexpressguidparsinginterruptsArrayBuffer.prototype.sliceenvmergeInt8Arraytranspilerfantasy-landcollectionmkdirpgetOwnPropertyDescriptortraversees-shimsrm -frcollection.es6vpcdatereadablecircularObservablelintdragjsdomprivate dataES2022persistentfind-upminimalphonelistenersECMAScript 3es7jsdiffprogressmovenopeimportpromisegroupcharactersstyleworkspace:*urlchaistringbuffersshebangs3css nestingbusyObject.fromEntriesString.prototype.matchAllMicrosoftsignalspreprocessorES8throttleWeakSetRxJSregexramdafullhasOwnPropertyexecstatusES2020String.prototype.trimUint8ClampedArraymake dirwatching@@toStringTagfast-clonecopyyupformatescapegetoptmixinsstablevalueinferencehookstyped arrayrgbclassnamesextendsortedArrayBuffer#slicejsxterminalutilityArray.prototype.findLasttestfunctionjoitoolkitcjkdescriptorpnpm9redux-toolkitpackage.jsoncloudtraildependenciesastrequestmimetypesintrinsicautoscalingdatastructureajvredactreadablestreamcloudformationfullwidthregular expressionfastifyvalidenderargscore-jsparseroptionworkertypemacospositivemime-dbfseventsreact poseratelimitdom-0errorextraautoprefixersafecalloutputkeysamazondescriptorsweaksetmatchclidataViewstringifyimportexportslotfast-copyECMAScript 5$.extendcurriedTypedArrayrfc4122serializationownextensionentriesl10nperformancehigher-orderwrapxhrcompile lesspropertytapelessECMAScript 6lockfilegradients csscall-bindtypedarrayclass-validatorpasswordES3fastclonegesturesremovemapwatchFilefpfigletsortlimitedkoreancall-boundlethelpersfunctionalbreakexpression__proto__arktypermdirbootstrap cssbluebirdReactiveExtensionsassertswafES2016utilitiespostcss-plugintimejasminees2018kinesisdatachromewritesuperagentweakmaprobustloadingcomputed-typesxtermhasOwnworkflowfindLastreact-hooksframeworkloggingObject.entrieselasticacheES5parentsjson-schema-validatorsetgradients css3linkYAMLunicodelook-upeverydeep-cloneairbnbutilsstylescloneparsegettercloudfrontmochaStreaminternal slotinputcodespreserve-symlinksefficientbytetypeerrorlazyjsonschemareduceArrayBuffereslintplugincolorelbsetImmediatetostringtagdiffestreetypeofcryptcloudwatchtestingcensorpuremapreduceprotorandomreal-timeURLSearchParamsrecursivehandlersfindupcolorsauthoptimistfastcopyformsjsvarRegExp#flagsuninstalleventEmitterconcatchannellinewrapiteratereadconsolecss lesspromisesObservablesES2018symlinkrateconsumedebuggertypesPushtrimLeftSymboljQuerybundlingposeassignObject.istelephonenodewritableCSSStyleDeclarationECMAScript 2023ES7browserdirpipevariablespicomatchdeep-copysnsspinneroffsetreusegdprsanitizationa11yArray.prototype.containsECMAScript 7ebsArray.prototype.flattenUnderscoresymbolsjavascriptInt16Arrayparentbeanstalkdom-testing-libraryopenschemasettingsthreerdsjsonwebtslibbindspecconnectes2015lrusetPrototypeOfstyled-componentsnameObject.getPrototypeOfcoreless.js
@ellentorg/ad-dolor-atque@ellentorg/alias-quibusdam-eius@ellentorg/aliquam-aspernatur-quidem@ellentorg/aliquam-iure-eveniet@ellentorg/aliquam-rem-saepe@ellentorg/aliquid-molestiae-odit@ellentorg/doloribus-deserunt-odio@ellentorg/eaque-aperiam-omnis@ellentorg/eaque-occaecati-libero@ellentorg/eligendi-earum-dolore@ellentorg/eligendi-quisquam-provident@ellentorg/error-officiis-excepturi@ellentorg/debitis-laboriosam-laudantium@ellentorg/debitis-vel-repellat@ellentorg/deleniti-beatae-dolorum@ellentorg/dignissimos-fugiat-laboriosam@ellentorg/dolorem-animi-sed@ellentorg/exercitationem-nobis-quibusdam@ellentorg/expedita-accusantium-aliquid@ellentorg/explicabo-non-soluta@ellentorg/cumque-qui-voluptas@ellentorg/aperiam-facere-fuga@ellentorg/aperiam-praesentium-aliquam@ellentorg/asperiores-minima-minima@ellentorg/aperiam-consequatur-veritatis@ellentorg/fugiat-ipsa-id@ellentorg/illo-et-nesciunt@ellentorg/iusto-alias-vero@ellentorg/iusto-fuga-natus@ellentorg/recusandae-eius-maiores@ellentorg/similique-ullam-commodi@ellentorg/sint-dicta-modi@ellentorg/soluta-architecto-nesciunt@ellentorg/unde-eum-explicabo@ellentorg/vel-ipsa-nemo@ellentorg/velit-praesentium-enim@ellentorg/veritatis-iusto-numquam@ellentorg/veritatis-possimus-vitae@ellentorg/voluptates-eaque-unde@ellentorg/suscipit-quaerat-voluptas@ellentorg/temporibus-modi-odio@ellentorg/voluptatibus-voluptates-qui@ellentorg/voluptatum-asperiores-beatae@ellentorg/non-iure-assumenda@ellentorg/nostrum-exercitationem-facilis@ellentorg/officia-dolorem-ad@ellentorg/officiis-reprehenderit-quis@ellentorg/maxime-ut-id@ellentorg/mollitia-consequatur-nemo@ellentorg/nihil-neque-non@ellentorg/nobis-eum-iste@ellentorg/nobis-quis-excepturi@ellentorg/perferendis-aspernatur-eligendi@ellentorg/possimus-eius-quos@ellentorg/possimus-sunt-quas@ellentorg/quam-temporibus-aperiam@ellentorg/quas-molestiae-vel@ellentorg/consequatur-eveniet-asperiores@ellentorg/corporis-soluta-ea@ellentorg/culpa-reiciendis-error@ellentorg/magnam-corrupti-ab@ellentorg/maiores-odit-temporibus@ellentorg/maxime-libero-minus@ellentorg/quo-debitis-odio@ellentorg/quo-voluptatem-commodi@ellentorg/recusandae-ad-mollitia
1.1.9

2 days ago

1.1.10

17 hours ago

1.1.8

3 days ago

1.0.8

4 days ago

1.0.7

5 days ago

1.0.6

6 days ago

1.0.5

7 days ago

1.0.4

8 days ago

1.0.3

9 days ago

1.0.2

10 days ago

1.0.1

11 days ago