4.17.134 • Published 11 months ago

@ellentorg/literate v4.17.134

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months 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/debitis-laboriosam-laudantium@ellentorg/alias-quibusdam-eius@ellentorg/asperiores-minima-minima@ellentorg/deleniti-beatae-dolorum@ellentorg/eaque-aperiam-omnis@ellentorg/dolorem-animi-sed@ellentorg/corporis-soluta-ea@ellentorg/temporibus-modi-odio@ellentorg/maxime-libero-minus@ellentorg/iusto-fuga-natus@ellentorg/eligendi-quisquam-provident@ellentorg/eligendi-earum-dolore@ellentorg/mollitia-consequatur-nemo@ellentorg/nihil-neque-non@ellentorg/nobis-eum-iste@ellentorg/quo-voluptatem-commodi@ellentorg/sint-dicta-modi@ellentorg/quo-debitis-odio@ellentorg/soluta-architecto-nesciunt@ellentorg/recusandae-ad-mollitia@ellentorg/recusandae-eius-maiores@ellentorg/similique-ullam-commodi@ellentorg/suscipit-quaerat-voluptas@ellentorg/exercitationem-nobis-quibusdam@ellentorg/cumque-qui-voluptas@ellentorg/doloribus-deserunt-odio@ellentorg/culpa-reiciendis-error@ellentorg/debitis-vel-repellat@ellentorg/error-officiis-excepturi@ellentorg/eaque-occaecati-libero@ellentorg/dignissimos-fugiat-laboriosam@ellentorg/expedita-accusantium-aliquid@ellentorg/perferendis-aspernatur-eligendi@ellentorg/quas-molestiae-vel@ellentorg/quam-temporibus-aperiam@ellentorg/possimus-eius-quos@ellentorg/possimus-sunt-quas@ellentorg/ad-dolor-atque@ellentorg/officiis-reprehenderit-quis@ellentorg/explicabo-non-soluta@ellentorg/nobis-quis-excepturi@ellentorg/magnam-corrupti-ab@ellentorg/maiores-odit-temporibus@ellentorg/maxime-ut-id@ellentorg/aliquam-aspernatur-quidem@ellentorg/aperiam-facere-fuga@ellentorg/aperiam-praesentium-aliquam@ellentorg/consequatur-eveniet-asperiores@ellentorg/aperiam-consequatur-veritatis@ellentorg/aliquam-rem-saepe@ellentorg/aliquid-molestiae-odit@ellentorg/aliquam-iure-eveniet@ellentorg/fugiat-ipsa-id@ellentorg/iusto-alias-vero@ellentorg/illo-et-nesciunt@ellentorg/voluptates-eaque-unde@ellentorg/voluptatibus-voluptates-qui@ellentorg/unde-eum-explicabo@ellentorg/vel-ipsa-nemo@ellentorg/voluptatum-asperiores-beatae@ellentorg/velit-praesentium-enim@ellentorg/veritatis-possimus-vitae@ellentorg/veritatis-iusto-numquam@ellentorg/nostrum-exercitationem-facilis@ellentorg/officia-dolorem-ad@ellentorg/non-iure-assumenda
3.13.103

1 year ago

3.4.47

1 year ago

3.13.102

1 year ago

3.6.69

1 year ago

3.4.48

1 year ago

3.13.101

1 year ago

3.4.49

1 year ago

3.13.100

1 year ago

3.13.107

1 year ago

3.13.106

1 year ago

3.13.105

1 year ago

3.13.104

1 year ago

3.13.109

1 year ago

3.13.108

1 year ago

4.15.118

12 months ago

3.4.45

1 year ago

4.15.119

12 months ago

3.4.46

1 year ago

3.10.93

1 year ago

3.10.92

1 year ago

4.15.120

12 months ago

3.13.110

1 year ago

3.13.114

1 year ago

3.4.58

1 year ago

3.13.113

1 year ago

3.4.59

1 year ago

3.13.112

1 year ago

3.13.111

1 year ago

3.4.50

1 year ago

3.4.51

1 year ago

3.4.52

1 year ago

3.4.53

1 year ago

3.4.54

1 year ago

3.4.55

1 year ago

3.4.56

1 year ago

3.4.57

1 year ago

2.3.39

1 year ago

2.3.38

1 year ago

2.3.37

1 year ago

2.3.36

1 year ago

3.6.72

1 year ago

3.6.71

1 year ago

3.6.70

1 year ago

4.17.129

12 months ago

4.17.127

12 months ago

4.17.128

12 months ago

4.17.121

12 months ago

4.17.122

12 months ago

3.12.99

1 year ago

4.17.125

12 months ago

4.17.126

12 months ago

4.17.123

12 months ago

3.15.118

12 months ago

4.17.124

12 months ago

3.15.117

12 months ago

2.1.27

1 year ago

2.1.28

1 year ago

2.3.42

1 year ago

2.3.41

1 year ago

2.3.40

1 year ago

3.8.74

1 year ago

3.8.75

1 year ago

3.8.72

1 year ago

3.8.73

1 year ago

3.9.90

1 year ago

3.7.72

1 year ago

3.9.91

1 year ago

3.9.92

1 year ago

3.5.69

1 year ago

3.5.68

1 year ago

3.5.67

1 year ago

3.5.66

1 year ago

3.5.65

1 year ago

3.5.64

1 year ago

3.5.63

1 year ago

3.5.62

1 year ago

4.17.132

12 months ago

4.17.133

12 months ago

4.17.130

12 months ago

4.17.131

12 months ago

4.17.134

11 months ago

2.2.28

1 year ago

2.2.29

1 year ago

3.5.61

1 year ago

2.4.43

1 year ago

2.4.42

1 year ago

2.4.45

1 year ago

2.4.44

1 year ago

3.9.79

1 year ago

3.9.77

1 year ago

3.9.78

1 year ago

3.4.61

1 year ago

3.14.115

1 year ago

3.14.114

1 year ago

3.14.117

1 year ago

3.14.116

1 year ago

2.2.35

1 year ago

2.2.36

1 year ago

2.2.33

1 year ago

3.4.60

1 year ago

2.2.34

1 year ago

4.16.120

12 months ago

3.9.75

1 year ago

2.2.31

1 year ago

4.16.121

12 months ago

3.9.76

1 year ago

2.2.32

1 year ago

2.2.30

1 year ago

3.9.88

1 year ago

3.9.89

1 year ago

3.11.97

1 year ago

3.11.96

1 year ago

3.11.99

1 year ago

3.11.98

1 year ago

3.12.100

1 year ago

3.11.93

1 year ago

3.11.95

1 year ago

3.11.94

1 year ago

3.9.86

1 year ago

3.9.87

1 year ago

3.9.84

1 year ago

3.9.85

1 year ago

3.9.82

1 year ago

3.9.83

1 year ago

3.9.80

1 year ago

3.9.81

1 year ago

2.1.26

1 year ago

2.1.25

1 year ago

2.1.24

1 year ago

1.1.23

1 year ago

1.1.24

1 year ago

1.1.22

1 year ago

1.1.21

1 year ago

1.1.20

1 year ago

1.1.19

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.12

1 year ago

1.1.13

1 year ago

1.1.11

1 year ago

1.1.9

1 year ago

1.1.10

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