Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.markdown 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. # json-stable-stringify
  2. This is the same as https://github.com/substack/json-stable-stringify but it doesn't depend on libraries without licenses (jsonify).
  3. deterministic version of `JSON.stringify()` so you can get a consistent hash
  4. from stringified results
  5. You can also pass in a custom comparison function.
  6. [![browser support](https://ci.testling.com/substack/json-stable-stringify.png)](https://ci.testling.com/substack/json-stable-stringify)
  7. [![build status](https://secure.travis-ci.org/substack/json-stable-stringify.png)](http://travis-ci.org/substack/json-stable-stringify)
  8. # example
  9. ``` js
  10. var stringify = require('json-stable-stringify');
  11. var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 };
  12. console.log(stringify(obj));
  13. ```
  14. output:
  15. ```
  16. {"a":3,"b":[{"x":4,"y":5,"z":6},7],"c":8}
  17. ```
  18. # methods
  19. ``` js
  20. var stringify = require('json-stable-stringify')
  21. ```
  22. ## var str = stringify(obj, opts)
  23. Return a deterministic stringified string `str` from the object `obj`.
  24. ## options
  25. ### cmp
  26. If `opts` is given, you can supply an `opts.cmp` to have a custom comparison
  27. function for object keys. Your function `opts.cmp` is called with these
  28. parameters:
  29. ``` js
  30. opts.cmp({ key: akey, value: avalue }, { key: bkey, value: bvalue })
  31. ```
  32. For example, to sort on the object key names in reverse order you could write:
  33. ``` js
  34. var stringify = require('json-stable-stringify');
  35. var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 };
  36. var s = stringify(obj, function (a, b) {
  37. return a.key < b.key ? 1 : -1;
  38. });
  39. console.log(s);
  40. ```
  41. which results in the output string:
  42. ```
  43. {"c":8,"b":[{"z":6,"y":5,"x":4},7],"a":3}
  44. ```
  45. Or if you wanted to sort on the object values in reverse order, you could write:
  46. ```
  47. var stringify = require('json-stable-stringify');
  48. var obj = { d: 6, c: 5, b: [{z:3,y:2,x:1},9], a: 10 };
  49. var s = stringify(obj, function (a, b) {
  50. return a.value < b.value ? 1 : -1;
  51. });
  52. console.log(s);
  53. ```
  54. which outputs:
  55. ```
  56. {"d":6,"c":5,"b":[{"z":3,"y":2,"x":1},9],"a":10}
  57. ```
  58. ### space
  59. If you specify `opts.space`, it will indent the output for pretty-printing.
  60. Valid values are strings (e.g. `{space: \t}`) or a number of spaces
  61. (`{space: 3}`).
  62. For example:
  63. ```js
  64. var obj = { b: 1, a: { foo: 'bar', and: [1, 2, 3] } };
  65. var s = stringify(obj, { space: ' ' });
  66. console.log(s);
  67. ```
  68. which outputs:
  69. ```
  70. {
  71. "a": {
  72. "and": [
  73. 1,
  74. 2,
  75. 3
  76. ],
  77. "foo": "bar"
  78. },
  79. "b": 1
  80. }
  81. ```
  82. ### replacer
  83. The replacer parameter is a function `opts.replacer(key, value)` that behaves
  84. the same as the replacer
  85. [from the core JSON object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_native_JSON#The_replacer_parameter).
  86. # install
  87. With [npm](https://npmjs.org) do:
  88. ```
  89. npm install json-stable-stringify
  90. ```
  91. # license
  92. MIT