{"name":"sanctuary-show","version":"3.0.0","description":"Evaluable string representations","license":"MIT","repository":{"type":"git","url":"git://github.com/sanctuary-js/sanctuary-show.git"},"dependencies":{},"devDependencies":{"sanctuary-scripts":"5.0.x"},"scripts":{"doctest":"sanctuary-doctest","lint":"sanctuary-lint","release":"sanctuary-release","test":"npm run lint && sanctuary-test && npm run doctest"},"mocha":{"ui":"tdd"},"gitHead":"a00417cfe3275ac12ce83c80b29d8b5181db6dfc","bugs":{"url":"https://github.com/sanctuary-js/sanctuary-show/issues"},"homepage":"https://github.com/sanctuary-js/sanctuary-show#readme","_id":"sanctuary-show@3.0.0","_nodeVersion":"14.15.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-gYWfafNMh9s7lsLma2qQe6M10H9cKNIGPXhks+yRLsiPdhN+lkThKVKSa53awyuxzGHecholjZZIpYEM5n7EVg==","shasum":"f7d8f8ec68e2da0b8392942a6f7dae0033535c6c","tarball":"http://registry-npm.ywwl.com/sanctuary-show/download/sanctuary-show-3.0.0.tgz","fileCount":4,"unpackedSize":8796,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh6A80CRA9TVsSAnZWagAA5EcP/RtTcG+U1Busc/skI3e0\ni0J7ovwE5Hx18dUROS39ae+LYGsYXeT/PQxlzIzHTUFg01zibyy5gcSSaGJP\nlZaWXo8c5x5hRRKy60qsvbz2xfbVzAawmCTYN94yTMwu79llwJGaRFyLogc0\nnN2/ubuoWQw09+uhIQZNGzUYG2y4ggKLdb4hiCXUa5XDi4Hkk/8KkIMvtyg+\ncBbkuYiZvwcycZUE6hfG+h5OUXlQjWwPOTsSDMRg59eYI18fvLlHJg7Y5R0f\nONenW8CUhfhee9weVxrPtJchKAHLIbGNNniOLi6K7btwuehVWh73SvZXJPuG\nKeIN+eQi6VTMoUsN7ktanFIAsFr+D1qz0MEy/1DG19CDCLuoWtNTS28dpMzZ\ntt7n7dUe5HyJubLhxMGSwRFstB5Nrd2Zna80pls9wU24qhs0s4zucYiG4mr9\nY7b++8KoVzEkevxZAm12nyKDseGCaXNWXZzzKTvZ3B5gLqV688mGDEIvqIfz\na2vzhHc/XVIh5821Df7GV2sv2KzBHM9r5LwjgwjveVD4l0CJjAwHRmL/sO0d\n28RWN6QU2UISmwICn/D3h900bKCoICOt1NaUUz9mFmlYs2Yf8p0JSfCLbSyK\n527tH/XoNKwpmlP1cp4OAZLfy1dv7FGvqc6+KAVq9ZsTgCP+Do/Mk7uY981d\nBFSI\r\n=5E6S\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDdoLpMEM83krNvXxvluhIydxoZT5UZSDZRFm4v5RH/ygIgC/U2v1nx1RzNnOiuqsbXUq4VcDTAyoyqXjEM7RQ1Egw="}],"size":3087,"noattachment":false,"key":"/sanctuary-show/-/sanctuary-show-3.0.0.tgz"},"_npmUser":{"name":"davidchambers","email":"dc@davidchambers.me"},"directories":{},"maintainers":[{"name":"davidchambers","email":"dc@davidchambers.me"},{"name":"avaq","email":"npmjs@account.avaq.it"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sanctuary-show_3.0.0_1642598195913_0.6600910954014789"},"_hasShrinkwrap":false,"readme":"# sanctuary-show\n\nHaskell has a `show` function which can be applied to a compatible value to\nproduce a descriptive string representation of that value. The idea is that\nthe string representation should, if possible, be an expression which would\nproduce the original value if evaluated.\n\nThis library provides a similar [`show`](#show) function.\n\nIn general, this property should hold: `eval (show (x)) = x`. In some cases\nparens are necessary to ensure correct interpretation (`{}`, for example,\nis an empty block rather than an empty object in some contexts). Thus the\nproperty is more accurately stated `eval ('(' + show (x) + ')') = x`.\n\nOne can make values of a custom type compatible with [`show`](#show) by\ndefining a `@@show` method. For example:\n\n```javascript\n//# Maybe#@@show :: Maybe a ~> () -> String\n//.\n//. ```javascript\n//. > show (Nothing)\n//. 'Nothing'\n//.\n//. > show (Just (['foo', 'bar', 'baz']))\n//. 'Just ([\"foo\", \"bar\", \"baz\"])'\n//. ```\nMaybe.prototype['@@show'] = function() {\n  return this.isNothing ? 'Nothing' : 'Just (' + show (this.value) + ')';\n};\n```\n\n### <a name=\"show\" href=\"https://github.com/sanctuary-js/sanctuary-show/blob/v3.0.0/index.js#L62\">`show :: Showable a => a -⁠> String`</a>\n\nReturns a useful string representation of the given value.\n\nDispatches to the value's `@@show` method if present.\n\nWhere practical, `show (eval ('(' + show (x) + ')')) = show (x)`.\n\n```javascript\n> show (null)\n'null'\n\n> show (undefined)\n'undefined'\n\n> show (true)\n'true'\n\n> show (new Boolean (false))\n'new Boolean (false)'\n\n> show (-0)\n'-0'\n\n> show (NaN)\n'NaN'\n\n> show (new Number (Infinity))\n'new Number (Infinity)'\n\n> show ('foo\\n\"bar\"\\nbaz\\n')\n'\"foo\\\\n\\\\\"bar\\\\\"\\\\nbaz\\\\n\"'\n\n> show (new String (''))\n'new String (\"\")'\n\n> show (['foo', 'bar', 'baz'])\n'[\"foo\", \"bar\", \"baz\"]'\n\n> show ([[[[[0]]]]])\n'[[[[[0]]]]]'\n\n> show ({x: [1, 2], y: [3, 4], z: [5, 6]})\n'{\"x\": [1, 2], \"y\": [3, 4], \"z\": [5, 6]}'\n```\n","publish_time":1642598196056,"_cnpm_publish_time":1642598196056,"dist-tags":{"latest":"3.0.0"}}