1.0.0 • Published 17 days ago

@ptkhanh94npm/corporis-ut-impedit v1.0.0

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

@ptkhanh94npm/corporis-ut-impedit 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('@ptkhanh94npm/corporis-ut-impedit');
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

readableperformantcolourthrottleWebSocketsthroatJSON-Schemaless mixinsloggerES6tslibbannerprototypetypescriptlinewrapnopemimebabel-coremake dirES3Array.prototype.findLastassertbrowserES2018Object.assignprettyuuidhooksfromsameValueZerowatchingserializerasyncratedeep-clonematchescurlreduxlogfpgraphqliettyreadablestreamtouchECMAScript 7utilityidlecore-jsECMAScript 3outputtypesStreamvalidatorsortawaiteslintpluginfsindicatorexit-codeoptimizertypedfast-deep-clonesharedfantasy-landframeworkjsdomviewpropertiespackage.jsonmimetypesfseventstc39class-validatorpushRxStyleSheetmochafind-upvalidatelinthigher-ordermetadataYAMLconcatstructuredClonesymlinkuser-streamsaccessorrfc4122timeURLponyfillyamlkeyscryptotextESthreeemitfindjshttpsECMAScript 2023extrabundlingtypedarraysfileminimalschemeerror-handlingcomparetypesafeArray.prototype.containsbusygetoptES2015styled-componentseventDispatcherrobustinferencejestbrowserslistairbnbwatcherinstallerconfigurableparsernamesexitpostcss-pluginoptimistcopycoreObject.keyswatchnegative zerodefinecompilerdatebddmiddlewarexhrfetchStreamsoperating-systemArraytranspilejwtes-abstractletdeterministicdependenciesarteveryincludescurriedargvutilitieslesslastarraySetreact-hook-formdeepcloneclassespolyfilljsonwatchFileES5compile lessutilECMAScript 2018TypeScriptyupargumentless cssimmermapgroupByenvironmentsearchvalidationphonemobiledataViewstatelesswordbreakredux-toolkitlengthcall-bindAsyncIteratorjasminebatchECMAScript 2017classnamehttpslotrapiditeratergbtrimEndprotowgetutilspopmotionpreserve-symlinksArray.prototype.findLastIndexparsesortedchromedropstylesheetpackage managerpropertycensorSymbol.toStringTagpipefindLastirqecmascriptzerocoerciblerandomvalueprivate datatrimStartomitTypeBoxstringfull-widthframerhasdebuggerpicomatchwhatwgtoolkittoobjectwidthsetImmediatelimitlinkansidefinePropertyECMAScript 6boundObject.iscallbackprocessWeakSetasciiargparsetoStringTagworkerruntimelookxssfigletoncetoolsprogresscss lessReactiveXawesomesaucel10nstreamsigtermclassnamessanitizewaapidotenvsuperagent$.extendxtermiteratorrequiresuperstructteststringifierObject.getPrototypeOftermWeakMapprefixUint16Arrayunicodechinesereact-hooksloadingbyteOffsetflates2018ratelimitautoprefixerobjtestingRFC-6455karmaes2016String.prototype.trimsafesymlinksfindLastIndexdescriptionspecwebUnderscorebytestableES2022east-asian-widthshrinkwrapFloat32ArrayprotobufObjectbreakpatchECMAScript 5guidflattenmergePromiseramdareact poseInt16Arraywalkcomputed-typesvisualmonorepotaskMicrosoftspinnersdayjscjkfullwordwrapremoveInt32Arraycss nestingstreamsgradients css3dpackagesECMAScript 2016circulareslint-pluginlanguagevalueslazya11yformspathpnpm9shelltypedarrayes5cliavarm -rfinvariantless compilerfast-copyjsxnamefastcopytrimRightcharactersdataviewfindupcall-boundregexserializejoinested cssnodejsregexpUint8ClampedArrayfixed-widthtesternegativeconcurrencyArrayBuffer#slicesetcreatecolorsparentsreducercss-in-jsfast-deep-copymrubrowserlistexecfunctiontyped arrayObservableObject.fromEntriesgetPrototypeOfinstallcolumnsES8tdd256setterwritestylingstylebyteLengthsignalscachereadclonecss variabletranspilerpluginquerystringquerydescriptorBigInt64ArraycommandershamuninstallES2016Array.prototype.flatMapmatchenderlrulibphonenumbercalleventEmitterbindtrimLeftformates8Object.entriesposecheckpropcollection.es6eslintconfigstyleguideemojiTypedArrayconsumeestreeasserts-0postcsstakeES2023inputreuseESnexthookformvalidmkdirssymbolsformreduceECMAScript 2015stylesrmdirdeleteflagschemajsonpatharktypeslicehasOwnbootstrap less6to5groupencryptiontrimfiltereventsdom-testing-libraryvariables in cssprivateglobsyntaxerrorgenericspoint-freechaiObservableschannelnpmpackageequalaccessibilityjsonschemadirtypaniontoArrayECMAScript 2021isConcatSpreadableutil.inspecttacitmakeduplex0HyBifunctionaldebugmatchAllsetPrototypeOfastargsmomentweaksetmkdirpdragapollooffsetwrappromisefoldertypeerrorsidewindowsES2020babelshebangReflect.getPrototypeOffastifyes7functionsvariableslistenersreactdeepperformancees-shimscryptjQueryelectronrangeerrorwarningcontainsextendECMAScript 2020bcryptES7jsdiffECMAScript 2019Iteratorequalityprunehelpershandlers_.extendajv.envimmutablebluebirdcharacterresolvegettercommand-linegetintrinsicinternal slotes2017queueMicrotasktypeFloat64ArraymkdirsignalfastflatMapwalkingopentoSortedqsInt8Arrayprotocol-bufferscallboundauthES2021urllimitedRegExp#flagsjapaneseharmonycallbindtostringtagsharedarraybufferregularsymbolcodesjson-schema-validatorreact animationjavascriptgradients css3json-schema-validationdirectoryES2019assertionURLSearchParamsinspectauthenticationJSONbundlerisbuffersfile systemspinnerextensionfastclonemacosintrinsicenveslintregular expressiongetOwnPropertyDescriptorconnectdeepcopyclientstatuscssconsolesomeBigUint64ArrayArray.prototype.includesdeep-copyzodsyntaxgestures@@toStringTagdatastructureshimdataRegExp.prototype.flagsUint8Arraymime-dbi18nArrayBuffer.prototype.sliceregular expressionswritablepromisestypeofarraysArray.prototype.flatWebSocketmixins__proto__
1.0.0

17 days ago