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_packagesip-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@harinderlabana/lotide@haijoon2/lotide@haijoon2/lotidee@efeerkmen/lotide@hassanabdi/lotide@kangarooswapfinance/v2-coretype-your-package-name-heretinymce-plugin-toyui4htmltip4@astro-my/sign-requestzona-xvue-router-generatoruni@kylesferrazza/graphql-relay-updated@livecycle.io/rrweb-snapshot@lawwwlin/lotide@laystack/quad-tree@louismcoding/lotide@lordbeanbag/vite-plugin-svg-icons-monorepo@legend02/lotide@lianc/lotide@lilyhabbs/lotide@linewit/vue-router-generator@litedexdev/litedexdev-default-token-list@litedexdev/litedex-core-swap@nguyen-thanh-tung/minisearch-synonyms@nibbs66/buttons-pkg@nightwatch/chai@nighly/sort-object-array-by-propertymoonwalkerswap-default-token-listsmkcp-solarpunkmiguelcostero-ng2-toastyots-deploy-toolsowt-client-javascriptnovacap-componentsroyman-experiment-npm-publishrckt-deployrcket-deploy
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