Dieses Repository beinhaltet HTML- und Javascript Code zur einer NotizenWebApp auf Basis von Web Storage. Zudem sind Mocha/Chai Tests im Browser enthalten. https://meinenotizen.netlify.app/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 3.9KB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <h1 align=center>
  2. <a href="http://chaijs.com" title="Chai Documentation">
  3. <img alt="ChaiJS" src="http://chaijs.com/img/chai-logo.png"/> pathval
  4. </a>
  5. </h1>
  6. <p align=center>
  7. Tool for Object value retrieval given a string path for <a href="http://nodejs.org">node</a> and the browser.
  8. </p>
  9. <p align=center>
  10. <a href="./LICENSE">
  11. <img
  12. alt="license:mit"
  13. src="https://img.shields.io/badge/license-mit-green.svg?style=flat-square"
  14. />
  15. </a>
  16. <a href="https://github.com/chaijs/pathval/releases">
  17. <img
  18. alt="tag:?"
  19. src="https://img.shields.io/github/tag/chaijs/pathval.svg?style=flat-square"
  20. />
  21. </a>
  22. <a href="https://travis-ci.org/chaijs/pathval">
  23. <img
  24. alt="build:?"
  25. src="https://img.shields.io/travis/chaijs/pathval/master.svg?style=flat-square"
  26. />
  27. </a>
  28. <a href="https://coveralls.io/r/chaijs/pathval">
  29. <img
  30. alt="coverage:?"
  31. src="https://img.shields.io/coveralls/chaijs/pathval/master.svg?style=flat-square"
  32. />
  33. </a>
  34. <a href="https://www.npmjs.com/packages/pathval">
  35. <img
  36. alt="npm:?"
  37. src="https://img.shields.io/npm/v/pathval.svg?style=flat-square"
  38. />
  39. </a>
  40. <a href="https://www.npmjs.com/packages/pathval">
  41. <img
  42. alt="dependencies:?"
  43. src="https://img.shields.io/npm/dm/pathval.svg?style=flat-square"
  44. />
  45. </a>
  46. <a href="">
  47. <img
  48. alt="devDependencies:?"
  49. src="https://img.shields.io/david/chaijs/pathval.svg?style=flat-square"
  50. />
  51. </a>
  52. <br/>
  53. <a href="https://saucelabs.com/u/chaijs-pathval">
  54. <img
  55. alt="Selenium Test Status"
  56. src="https://saucelabs.com/browser-matrix/chaijs-pathval.svg"
  57. />
  58. </a>
  59. <br>
  60. <a href="https://chai-slack.herokuapp.com/">
  61. <img
  62. alt="Join the Slack chat"
  63. src="https://img.shields.io/badge/slack-join%20chat-E2206F.svg?style=flat-square"
  64. />
  65. </a>
  66. <a href="https://gitter.im/chaijs/chai">
  67. <img
  68. alt="Join the Gitter chat"
  69. src="https://img.shields.io/badge/gitter-join%20chat-D0104D.svg?style=flat-square"
  70. />
  71. </a>
  72. </p>
  73. ## What is pathval?
  74. Pathval is a module which you can use to retrieve or set an Object's property for a given `String` path.
  75. ## Installation
  76. ### Node.js
  77. `pathval` is available on [npm](http://npmjs.org). To install it, type:
  78. $ npm install pathval
  79. ### Browsers
  80. You can also use it within the browser; install via npm and use the `pathval.js` file found within the download. For example:
  81. ```html
  82. <script src="./node_modules/pathval/pathval.js"></script>
  83. ```
  84. ## Usage
  85. The primary export of `pathval` is an object which has the following methods:
  86. * `hasProperty(object, name)` - Checks whether an `object` has `name`d property or numeric array index.
  87. * `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`.
  88. * `getPathValue(object, path)` - Retrieves the value of a property at a given `path` inside an `object`'.
  89. * `setPathValue(object, path, value)` - Sets the `value` of a property at a given `path` inside an `object`'.
  90. ```js
  91. var pathval = require('pathval');
  92. ```
  93. #### .hasProperty(object, name)
  94. ```js
  95. var pathval = require('pathval');
  96. var obj = { prop: 'a value' };
  97. pathval.hasProperty(obj, 'prop'); // true
  98. ```
  99. #### .getPathInfo(object, path)
  100. ```js
  101. var pathval = require('pathval');
  102. var obj = { earth: { country: 'Brazil' } };
  103. pathval.getPathInfo(obj, 'earth.country'); // { parent: { country: 'Brazil' }, name: 'country', value: 'Brazil', exists: true }
  104. ```
  105. #### .getPathValue(object, path)
  106. ```js
  107. var pathval = require('pathval');
  108. var obj = { earth: { country: 'Brazil' } };
  109. pathval.getPathValue(obj, 'earth.country'); // 'Brazil'
  110. ```
  111. #### .setPathValue(object, path, value)
  112. ```js
  113. var pathval = require('pathval');
  114. var obj = { earth: { country: 'Brazil' } };
  115. pathval.setPathValue(obj, 'earth.country', 'USA');
  116. obj.earth.country; // 'USA'
  117. ```