1.0.0 • Published 1 year ago

@crabas0npm/quae-ipsa-inventore v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@crabas0npm/quae-ipsa-inventore Version Badge

github actions coverage License Downloads

npm badge

Returns true if a value has the characteristics of a valid JavaScript data descriptor.

Examples

true when the descriptor has valid properties with valid values. false when not an object or when the object has invalid properties.

var isDataDesc = require('@crabas0npm/quae-ipsa-inventore');
var assert = require('assert');

assert.equal(true, isDataDesc({ value: 'foo' }));
assert.equal(true, isDataDesc({ value: function () {} }));
assert.equal(true, isDataDesc({ value: true }));

assert.equal(false, isDataDesc('a'));
assert.equal(false, isDataDesc(null));
assert.equal(false, isDataDesc([]));

assert.equal(false, isDataDesc({ value: 'foo', bar: 'baz' }));
assert.equal(false, isDataDesc({ value: 'foo', bar: 'baz' }));
assert.equal(false, isDataDesc({ value: 'foo', get: function () {} }));
assert.equal(false, isDataDesc({ get: function () {}, value: 'foo' }) );
 
assert.equal(false, isDataDesc({ value: 'foo', enumerable: 'foo' }));
assert.equal(false, isDataDesc({ value: 'foo', configurable: 'foo' }));
assert.equal(false, isDataDesc({ value: 'foo', writable: 'foo' }));

Valid properties

The only valid data descriptor properties are the following:

  • configurable (required)
  • enumerable (required)
  • value (optional)
  • writable (optional)

To be a valid data descriptor, either value or writable must be defined.

Invalid properties

A descriptor may have additional invalid properties (an error will not be thrown).

var foo = {};

Object.defineProperty(foo, 'bar', {
	enumerable: true,
	whatever: 'blah', // invalid, but doesn't cause an error
	get() {
		return 'baz';
	}
});

assert.equal(foo.bar, 'baz');

Related projects

  • is-accessor-descriptor: Returns true if a value has the characteristics of a valid JavaScript accessor descriptor.
  • is-descriptor: Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for… more

Tests

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

importexportbyteLengthdescriptiontimeimportchromestyleguideTypeScripthelpersdeepBigInt64Arraycomputed-typescharactersfindLastIndexrateArrayBuffer.prototype.sliceweakmapstoragegatewaytrimswfpreprocessorappfastcloneUint8ArrayemojiimmerArray.prototype.flattenrm -frdependency managertypedarraysESurllook-upmodulespathCSSSetECMAScript 2020stringifyrmbufferswalkingInt8ArrayescapestdlibcachemapreduceTypedArray0validationconnectcssmovetypesafevpccloudwatch__proto__east-asian-widthFloat64ArrayconfigurablenamedropPushmomenttc39ajaxphonehasschemereducerjsxenvsigtermrapidsetImmediatelinkFunction.prototype.namees2017jQuerydataViewInt16ArrayhotsuperstructkoreansymbolsautoscalingperformancepredictableresolveRxviewyupeslint-pluginUnderscoreterminalvariablesmimepostcss-plugindebuggercore-jsserializeavaclassnamedeep-copymimetypestakedotenvinterruptsasynceventscall-bindcloudformationtypeofincludeses2015browserlistguiddatareact-hooksassertcode pointsajvfindLastmonorepoqueueMicrotaskparsinglimites8datastructuretypedconcurrencyInt32ArrayspecparentidentifiersmrutrimRight@@toStringTagmodulecommandelasticacheserializationloadingObject.isimmutablehttpflagsmatchesECMAScript 5fromcloudsearchhas-ownjestencryptionObservablesyntaxerrorgetoptflatcss nestingtestes-abstractcloudtrailObject.getPrototypeOfcharacterdayjsspinnerfses2018ES7isprotostyleemrdeterministichasOwnPropertyexit-codewatchtypestapES2016frameworkextensionarrayenvironmentsvalidatecurlnopejsonpreserve-symlinksproxyestreelimitedlintdebugqueueargumentapiinvariantecmascriptthrottlefast-copywindowsdomwriteprototypeArray.prototype.findLastIndexredactarraysstringdom-testing-libraryansideepcloneobjownsnsiteratetscompilerworkspace:*asciijsdiffstyled-componentsworkercopyrandomES2019collection.es6fullsymboleslintpluginaccessorchaiObject.assignBigUint64Arraynumbercompile lessFloat32ArrayexitsafemochatelephoneiteratorreadabletouchprogressglobalString.prototype.matchAllcoercibleRegExp.prototype.flagsObject.entriesshebangcommand-lineObject.valuesjasmineassertionArray.prototype.filtercolumnprivate datareadablestreambannernegativelookconcatkarmaECMAScript 2023wordwraplazyexecpolyfillprunecss variablewritableclientbootstrap cssregularregexpsymlinkES2018-0eventEmitterlistenerscolorES2021StyleSheeterrorfastifyfetchless.jsawesomesaucezeroECMAScript 2016fixed-widthhandlerscorsdataviewpipeebsboundeverybyteArrayBuffer#slicebluebirdUint16ArrayreduxgetbcryptpackageslanguageintrinsicMaprequestES2022consumeweaksetjwtbyteOffsetcomparezodSymbolfileregular expressiontypescriptESnextwhatwgpackageformssideshimloadbalancingfastreuseequalthroatvestponyfillefficientmime-dbdiffec2busyquerystringes7mergespinnerserror-handlingjsdomauthenticationtypanionUint32ArrayaccessibilitysameValueZerobreakeslintwgettypeerrorpropertiesiamfluxshamcolumnsJSONupglobalsairbnbelbnegative zerotermtestingrfc4122bddWebSockettraversesignalpersistenttypedarraytoobjecttoArraybundlergradients css3PromiseRxJSpromiseCSSStyleDeclarationcensorendpointjapanesesharedES2020circularmixinshigher-orderlengthmakejoidirectorywalkcss lessloggerECMAScript 7statusSymbol.toStringTagequalityfast-deep-clonees6stylesformattingtddmiddlewaretapeJSON-SchematypedeepcopyjshintassertsargparsemobiletesterMicrosoftperformantwrapes-shim APIwebeslintconfigfunctionpatchfigletWebSocketsoperating-systempyyamlargslogrmdirdefinePropertyrgbglobparseAsyncIteratorArrayirqwatcherArray.prototype.findLastES6find-upless cssessignalscryptsortedio-tspnpm9symlinksa11ylesscssreadbrowserslistReactiveExtensionsmkdiri18nsetnested cssES5deletechromiumoffsetstreams2shrinkwrapbindclassesinstallerflattendires-shimsrequirestreamsECMAScript 3Array.prototype.flatMapchineseECMAScript 2017regular expressionscommandersorthookscallboundinspectreactuninstallwarningstylesheetRegExp#flagsmatchwatchFilesigintjsonpathgetOwnPropertyDescriptorutilityprotobufidwaflessfast-deep-copyreduceArray.prototype.includesreal-timebufferclibeanstalkmatchAllelectronfolderserializerschemapackage manager256class-validatorlasttrimStartonceTypeBoxrobustjavascriptl10nindicatorReactiveXinternal slotfile systemtoolsslotextranodejsObject.keyshardlinksrestfulcodesxtermwordbreakqueryglacierStreamsreact-hook-formtyped arrayprotocol-buffersRFC-6455varskeyschannelECMAScript 2021restprocessES2017Reflect.getPrototypeOfclonetostringtagES2023astlinuxargvclassnamesroute53[[Prototype]]searchwhichquoteECMAScript 6genericsnamespostcsskey$.extendomitsesutilitiescallstarterES8streamtoolkitcjkenvironmentObject.fromEntriesarraybufferprettymkdirsforEachObjecthttpsObject.definePropertyexpresscloudfrontruntimeStreamgraphqlURLSearchParamshookformisConcatSpreadabledynamodbsuperagentsinatrapropmkdirpnativeoptionloggingparentsmacoscreateArrayBufferobjectoutputlivetrimEndinternalgrouppicomatchpropertypackage.jsonstylingpromisesshellfindprivatestatedeep-cloneenumerableinferenceentrieskinesisinutil.inspecttrimLeftrangeerrorsettingscss-in-jslockfileautoprefixeriebatchidlesyntaxIteratorrm -rfyamlbrowsercallbackObservablesworkflowmapinputscheme-validationArray.prototype.flatxhrvisualminimalES2015_.extendtoStringTagrdspositiveYAMLrouterfseventsauthextendinstallspeedless mixinsfindupmetadataawaitvalueECMAScript 2022bootstrap lesselmform-validationconsolecolorswidthdefinehashURLoptimizerconfigenderttymake dirfunctionsmulti-packagecorecallbindreact-testing-libraryrecursivebundlingString.prototype.trimtoSortedfast-clonefunctionaljsuuidremoveparserstringifiertslibdescriptorsamazonfilterECMAScript 2015colourwaitlrugradients cssredux-toolkitconcatMaparktypesharedarraybuffercontainssomepluginwatchingflatMaplinewrapdescriptorhasOwnWeakMaptaskemitopenES3statelessECMAScript 2018textawsqsgetPrototypeOfcryptostructuredClonefpses2016collectionvaliditerationsetterapolloutil.envArray.prototype.containsfull-widthagentslicepasswordes5setPrototypeOfdatefullwidthsqspushprefixnpmvariables in csslibphonenumberWeakSetsequenceratelimitoptimistformHyBifastcopyUint8ClampedArraynodevaluesdependenciesassignstablegetterformats3ECMAScript 2019replayflagcall-boundless compilereventDispatchercheckartgroupByexpressionregex
1.0.0

1 year ago