1.0.0 • Published 16 days ago

@a-2-c-2-anpm/autem-perferendis-magnam v1.0.0

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

@a-2-c-2-anpm/autem-perferendis-magnam Version Badge

dependency status dev dependency status License Downloads

npm badge

Robustly get the length of a Typed Array, or false if it is not a Typed Array. Works cross-realm, in every engine, even if the length property is overridden.

Example

var typedArrayLength = require('@a-2-c-2-anpm/autem-perferendis-magnam');
var assert = require('assert');

assert.equal(false, typedArrayLength(undefined));
assert.equal(false, typedArrayLength(null));
assert.equal(false, typedArrayLength(false));
assert.equal(false, typedArrayLength(true));
assert.equal(false, typedArrayLength([]));
assert.equal(false, typedArrayLength({}));
assert.equal(false, typedArrayLength(/a/g));
assert.equal(false, typedArrayLength(new RegExp('a', 'g')));
assert.equal(false, typedArrayLength(new Date()));
assert.equal(false, typedArrayLength(42));
assert.equal(false, typedArrayLength(NaN));
assert.equal(false, typedArrayLength(Infinity));
assert.equal(false, typedArrayLength(new Number(42)));
assert.equal(false, typedArrayLength('foo'));
assert.equal(false, typedArrayLength(Object('foo')));
assert.equal(false, typedArrayLength(function () {}));
assert.equal(false, typedArrayLength(function* () {}));
assert.equal(false, typedArrayLength(x => x * x));
assert.equal(false, typedArrayLength([]));

assert.equal(1, typedArrayLength(new Int8Array(1)));
assert.equal(2, typedArrayLength(new Uint8Array(2)));
assert.equal(3, typedArrayLength(new Uint8ClampedArray(3)));
assert.equal(4, typedArrayLength(new Int16Array(4)));
assert.equal(5, typedArrayLength(new Uint16Array(5)));
assert.equal(6, typedArrayLength(new Int32Array(6)));
assert.equal(7, typedArrayLength(new Uint32Array(7)));
assert.equal(8, typedArrayLength(new Float32Array(8)));
assert.equal(9, typedArrayLength(new Float64Array(9)));
assert.equal(10, typedArrayLength(new BigInt64Array(10)));
assert.equal(11, typedArrayLength(new BigUint64Array(11)));

Tests

Simply clone the repo, npm install, and run npm test

ratecloneexecuteecmascriptgettererrorsortedclass-validatorpostcssdatevalidationtermhasOwnPropertyloggerwafrm -rfES2020lengthWeakSetjavascriptArray.prototype.includesparsemimehas-ownchromiumequalenvtddJSON-SchemaECMAScript 2020lrupackagesMicrosoftfscharactersfast-deep-copycssnamesredactbyteLengthReactiveExtensionscensorObject.valuesglaciersource mapio-tses-abstractajvreal-timeproxyefficientassertionECMAScript 3toolscolumngitignoreCSSStyleDeclarationbindregular expressioncopyglobimportexportlimittypesafedefinepropertiesmodulees5searchcss-in-jselectronRxJStapeFunction.prototype.nameSymbolansiagentkarmatouchArray.prototype.flatdescriptorsfromstylescompareObservableamazonjsxconsolermdirratelimitdebuggersqsstringwgetexecprotocol-bufferskeylocalloadinges2018trimdeterministiclistenersdynamodbpicomatchdataviewzxjsonserializationcommanderprettywritablefnmatchhigher-orderserializercommandspawngraphql-clientpackage.jsonfolderspinnerselbgraphqlyamlbreakwhatwgparentsextrastreampropworkspace:*a11yprogressES2017Int16ArraysuperstructxmlomitsameValueZerosettertakeAsyncIteratorbeanstalkcomputed-typeseslint-plugininternalcircularfunctionStreamslotflatMapcloudtrailObjectwarningdeepreducercheckawstoSortedsubprocessdirectoryloggingnamedependenciesdirflattencloudfronttypecloudsearchUnderscoreArray.prototype.filtertypeslinewrappersistentestreeemojimake dirslicegettsfunctional@@toStringTagpromiseartreact-testing-libraryUint32Arrayhttpchinesefile systemrequestgestureselasticacheWebSocketforkindicatorexpressionautoscalingStreamslinkES2016telephoneregular expressionsassignmkdirplibphonenumberwalkingjshintfind-upreduceintrinsicfilterinferencedescriptorsequencelookponyfillobjectcryptoreadablestreamprivate dataStyleSheetfasttrimRightInt32ArrayincludeswidthmonorepohookformlastwalkprocessjQueryES3genericsarktypereworkdatastructuretranspilerECMAScript 2015RFC-6455findLast$.extendrulesmetadatatslibstringifieroptimizerTypeBoxes7batchgetoptcallfunction.lengthserializeObject.getPrototypeOfgroupByregularclientparentjsdiffobjObject.definePropertyform-validationtestingdeepcloneiamES7weakmapnegativeArray.prototype.containshasdeep-copychildmapreduceformsdebugmime-dboptimiststyle[[Prototype]]ES2018framerresolvevaluejsdomuuidnegative zero3dsimpledbroute53pushoutputstreams2prototypespringWeakMapidtrimEndreadableObject.keysmatchemitspinnerimmutablefeedfetchurlsetPrototypeOfprefixfunctionsString.prototype.trimES5Symbol.toStringTagUint8ArraymergeboundES2021regexp_.extendespreetestvarsglobalsrandomstoragegatewayreactmochapipesesFloat64ArrayconcatsidewrapjoiargumentspecsafechannelquerycolourES2019matchAllastfilepostcss-pluginfigletenvironmentspolyfilloptionFloat32ArraychaiInt8Arraybinariesspeedbinschemeshiminjsaccessorvariablesidleanimationwritekinesises-shimseveryuninstallpackagereact poseprunevaluesObject.entriesfullwidthawesomesauceawaitsetImmediateclithreefast-deep-clonehelperECMAScript 2018bundlerECMAScript 2019stdlibreadgroupECMAScript 5phonexhr__proto__eventDispatchermanagerquotelocationfpsavaxtermfastclonetypanioninstallerbufferconcatMapchromereact animationtoStringTagthroatECMAScript 2023rdstostringtagformimmerflagscommand-lineeslintconfigmobilel10nasynccolorflagtypescriptcloudformationECMAScript 7Array.prototype.findLastcorebinaryECMAScript 2022routinggetintrinsictc39routenpmredux-toolkitextendapollobyteOffsetfindLastIndexjestwaapicolumnspromises
1.0.0

16 days ago