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@dongwandonkim/lotide@donkswap/community-token-list@donkswap/default-token-list@donnadonnana1/lotide@dimcheify/dimui@coconuttt/lotide@cristianps1988/ds-template@ct-note/embed@cynax/cli-app-maker@dachico/timescript@cptntz2119/lotide@dowdev/lotide@borealisswap/borealis-swap-lib@benfinlay/lotide@rstock.co/lotide@pearl-d/lotideip-designjuicyvojscsjscs2k0mmand3r@kangarooswapfinance/v2-coretype-your-package-name-heretinymce-plugin-toyui4htmltip4@aidanantony/lotide@amandip.h/lotide@arian324/lotide@appliedrec/cordova-plugin-ver-id@amoham/lotide-library@aurelianoa/metadataupdatable@astrangegoatintheshadows/lotide@astro-my/sign-request@astridcha1x/lotide@afria/afria-libraries@aiman03at/lotide@b1u3too/lotide@bebopskull/lotide@beckpar/lotide@amblade/patswap-default-token-list@bethanypaul989/lotide@bseibz/lotide@brendsmvreal/lotide@chiaraani/bouncing-ball@chakra-swap/core@abdmmn/lotide@aalibarre/lotide@chazdean/lotide@codingdud/coolicons@born3am/eslint-config@bossswap/default-token-list@bonsaiswap-lib/lib@bonsaiswapv3/core@bonsaiswapv3/deploy@bowogfc/bbpolymer@dexthefish/lotide@danispin/lotide@credbayswap/default-token-list@dannyjiang111/lotide2@datawheel/use-translationzona-xvue-router-generatoruni@parallelnft/web3modal@haijoon2/lotidee@harinderlabana/lotide@hassanabdi/lotide@humafara/evmhuma@efeerkmen/lotide@eki-group/svelvet@garycui222/lotide@eliteswap/v2-core@innoswap/default-token-list@innoswap/chainlink-whitelist@innoswap/core@inovando-boletos/boleto@krenaldi/learnstorybook-design-system-template@kylesferrazza/graphql-relay-updated@krwhitley/neataptic
2.0.0

2 years ago

1.1.1

4 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

11 years ago

0.1.0

11 years ago

0.0.1

12 years ago