2.0.0 • Published 10 months ago

pathval v2.0.0

Weekly downloads
3,435,544
License
MIT
Repository
github
Last release
10 months 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-2417vue-router-generator@erkanegesenli/lotide@erikandersonwebdev/lotide@ericmcornelius/ease@fabwcie/ckeditor5-preview@igniswap/igni-swap-lib@jarrettk/lotide@innoswap/default-token-list@innoswap/chainlink-whitelist@innoswap/core@lul-merina/lotide@lxfater/windows-scheduler@lukmanukir/gagalmuludah@luiscontreras/lotide@iridium7/lotide@itayn-fireberry-org/itayn-test@kacao/chops@manwelj/lotide@mar10outof10/lotide@kalkanisys/vue-selectdynamics-contracts-x@haijoon2/lotidee@harinderlabana/lotide@hassanabdi/lotide@hieuquang2212/form@hiroyone/number-formatter@humafara/evmhuma@eliteswap/v2-core@efeerkmen/lotide@eki-group/svelvet@garycui222/lotide@inovando-boletos/boleto@jenlaw266/lotide@jacquikoroll/lotide@lordbeanbag/vite-plugin-svg-icons-monorepo@jjsmile/lotide@jiaqi13/lotide@j-pilon/lotide@louismcoding/lotide@kylesferrazza/graphql-relay-updated@livecycle.io/rrweb-snapshot@olgatkachenko/lotide@olympfin/olymp-swap-lib@linewit/vue-router-generator@lilyhabbs/lotide@mzparulina26/lotide@namraa/lotide@oneverseswap/community-token-list@oneverseswap/default-token-list@mrludovic/lotide@litedexdev/litedex-core-swap@litedexdev/litedexdev-default-token-list@munahd/lotidedeepdetect-jsnode-red-contrib-cecnovacap-componentspixiu-swap-coreots-deploy-toolsowt-client-javascripttest-solidity-npmthe_helper_packagethe_helper_packagestinymce-plugin-toytape-chaisvelvet-customsparse-setroyman-experiment-npm-publishshadow-event-bussinon-doublistshainaproxy-rotator-jsreact-gen-wizardreact-gen-wizard-watsonptg-airdroppromise.barquadratic-sdkreverse-mustachereductoqudratic-uircket-deployrckt-deploytype-your-package-name-hereunitip4ui4htmlxmlmapperwinx-form-winxzona-x@mcl2s/lotide@mclap/lotide
2.0.0

10 months ago

1.1.1

3 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.1

10 years ago