2.0.0 • Published 2 years ago

pathval v2.0.0

Weekly downloads
3,435,544
License
MIT
Repository
github
Last release
2 years ago

What is pathval?

Pathval is a module which you can use to retrieve or set an Object's property for a given String path.

Installation

Node.js

pathval is available on npm. To install it, type:

$ npm install pathval

Browsers

You can also use it within the browser; install via npm and use the pathval.js file found within the download. For example:

<script src="./node_modules/pathval/pathval.js"></script>

Usage

The primary export of pathval is an object which has the following methods:

  • hasProperty(object, name) - Checks whether an object has named property or numeric array index.
  • getPathInfo(object, path) - Returns an object with info indicating the value of the parent of that path, the name of the property we're retrieving and its value.
  • getPathValue(object, path) - Retrieves the value of a property at a given path inside an object'.
  • setPathValue(object, path, value) - Sets the value of a property at a given path inside an object and returns the object in which the property has been set.
var pathval = require('pathval');

.hasProperty(object, name)

var pathval = require('pathval');

var obj = { prop: 'a value' };
pathval.hasProperty(obj, 'prop'); // true

.getPathInfo(object, path)

var pathval = require('pathval');

var obj = { earth: { country: 'Brazil' } };
pathval.getPathInfo(obj, 'earth.country'); // { parent: { country: 'Brazil'  }, name: 'country', value: 'Brazil', exists: true }

.getPathValue(object, path)

var pathval = require('pathval');

var obj = { earth: { country: 'Brazil' } };
pathval.getPathValue(obj, 'earth.country'); // 'Brazil'

.setPathValue(object, path, value)

var pathval = require('pathval');

var obj = { earth: { country: 'Brazil' } };
pathval.setPathValue(obj, 'earth.country', 'USA');

obj.earth.country; // 'USA'
chai@sonammalhotra/lotide@smishra17/lotide@cheapthrills/lotide@cujo-common/simple-hello-world-example@iobroker-community-adapters/iobroker.device-watcher@newhorizon-tech/dd-npm-package-template@nicholasjj/lotide@infinitebrahmanuniverse/nolb-path@everything-registry/sub-chunk-2417isomorphic-modeltape-chaisvelvet-customwinx-form-winxwith-defer-esxmlmappersparse-settest-solidity-npmthe_helper_packagethe_helper_packages@borealisswap/borealis-swap-lib@benfinlay/lotide@rstock.co/lotide@pearl-d/lotideip-designjuicyvojscsjscs2k0mmand3rhw9hybrid-chaihubot-budahippiehardhat-teaplughardhat-teaxyzhcm-jslodown-rayford-smithmakyomanufactorylotide2loading-animatedluis-response-builderluis-entity-builderknockout-configurations-extenderknockout-validations-error-handler@wesleymatthee/lotide@wojeong/lotide@xisha/lotide@xisha/lotide.@ukflava/lotide@thismr/bitmindtest-core@tzheng/lotide1@thedoctor0/vuex-shared-mutations@thahira_sheerin/lotide@xswap/v2-core@xusk_studio/geckoterminal-sdk@ya_lhl/lotide@xzess/localstoredb@yak-spirit/yak-swap-ui@zakwarsame/lotide@zabir.aa/lotide@zasal1990/lotide@terminusdb/terminusdb-clientabbas-ahlan-rouletteassertive-chai@iridium7/lotide@itayn-fireberry-org/itayn-test@aurelianoa/metadataupdatable@abdmmn/lotide@0xclearview/svelte-tiny-virtual-table@harinderlabana/lotide@aalibarre/lotide@b1u3too/lotide@haijoon2/lotide@haijoon2/lotidee@aiman03at/lotide@aidanantony/lotide@afria/afria-libraries@efeerkmen/lotide@codingdud/coolicons@coconuttt/lotide@cristianps1988/ds-template@credbayswap/default-token-list@amandip.h/lotide@hassanabdi/lotide@cptntz2119/lotide@amblade/patswap-default-token-list@amoham/lotide-library@kangarooswapfinance/v2-coretype-your-package-name-heretinymce-plugin-toyui4htmltip4@astro-my/sign-request@bebopskull/lotide@beckpar/lotide@bethanypaul989/lotide@bseibz/lotide@brendsmvreal/lotide@chiaraani/bouncing-ball
2.0.0

2 years ago

1.1.1

5 years ago

1.1.0

9 years ago

1.0.0

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.1

12 years ago

0.1.0

12 years ago

0.0.1

12 years ago