{"_id":"sanctuary-show","_rev":"4181721","name":"sanctuary-show","description":"Evaluable string representations","dist-tags":{"latest":"3.0.0"},"maintainers":[{"name":"avaq","email":""},{"name":"davidchambers","email":""}],"time":{"modified":"2026-03-01T21:52:50.000Z","created":"2018-04-29T17:06:41.200Z","3.0.0":"2022-01-19T13:16:36.056Z","2.0.0":"2020-01-17T15:00:21.014Z","1.0.0":"2018-04-29T17:06:41.200Z"},"users":{},"repository":{"type":"git","url":"git://github.com/sanctuary-js/sanctuary-show.git"},"versions":{"3.0.0":{"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":{"shasum":"f7d8f8ec68e2da0b8392942a6f7dae0033535c6c","size":3087,"noattachment":false,"key":"/sanctuary-show/-/sanctuary-show-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sanctuary-show/download/sanctuary-show-3.0.0.tgz"},"_npmUser":{"name":"davidchambers","email":"dc@davidchambers.me"},"directories":{},"maintainers":[{"name":"avaq","email":""},{"name":"davidchambers","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sanctuary-show_3.0.0_1642598195913_0.6600910954014789"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-01-19T13:16:54.480Z","publish_time":1642598196056,"_cnpm_publish_time":1642598196056},"2.0.0":{"name":"sanctuary-show","version":"2.0.0","description":"Evaluable string representations","license":"MIT","repository":{"type":"git","url":"git://github.com/sanctuary-js/sanctuary-show.git"},"dependencies":{},"devDependencies":{"sanctuary-scripts":"4.0.x"},"scripts":{"doctest":"sanctuary-doctest","lint":"sanctuary-lint","release":"sanctuary-release","test":"npm run lint && sanctuary-test && npm run doctest"},"gitHead":"3761b5f2cdc20ce1134575a702282575dda59d5d","bugs":{"url":"https://github.com/sanctuary-js/sanctuary-show/issues"},"homepage":"https://github.com/sanctuary-js/sanctuary-show#readme","_id":"sanctuary-show@2.0.0","_nodeVersion":"12.14.0","_npmVersion":"6.13.4","dist":{"shasum":"2326b4744f4b0f993f18ca56a29f68a50f514637","size":3018,"noattachment":false,"key":"/sanctuary-show/-/sanctuary-show-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sanctuary-show/download/sanctuary-show-2.0.0.tgz"},"maintainers":[{"name":"avaq","email":""},{"name":"davidchambers","email":""}],"_npmUser":{"name":"davidchambers","email":"dc@davidchambers.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sanctuary-show_2.0.0_1579273220899_0.6555976519375721"},"_hasShrinkwrap":false,"publish_time":1579273221014,"_cnpm_publish_time":1579273221014,"_cnpmcore_publish_time":"2021-12-16T18:30:49.364Z"},"1.0.0":{"name":"sanctuary-show","version":"1.0.0","description":"Evaluable string representations","license":"MIT","repository":{"type":"git","url":"git://github.com/sanctuary-js/sanctuary-show.git"},"files":["/LICENSE","/README.md","/index.js","/package.json"],"dependencies":{},"devDependencies":{"sanctuary-scripts":"1.5.x"},"scripts":{"doctest":"sanctuary-doctest","lint":"sanctuary-lint","release":"sanctuary-release","test":"npm run lint && sanctuary-test && npm run doctest"},"gitHead":"46f523012a0ffcd26f24caebce148733fb9a48ee","bugs":{"url":"https://github.com/sanctuary-js/sanctuary-show/issues"},"homepage":"https://github.com/sanctuary-js/sanctuary-show#readme","_id":"sanctuary-show@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"davidchambers","email":"dc@davidchambers.me"},"dist":{"shasum":"72deb4812f9decec850e03286807dca1c97a1d61","size":2962,"noattachment":false,"key":"/sanctuary-show/-/sanctuary-show-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/sanctuary-show/download/sanctuary-show-1.0.0.tgz"},"maintainers":[{"name":"avaq","email":""},{"name":"davidchambers","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sanctuary-show_1.0.0_1525021600824_0.7622912363000764"},"_hasShrinkwrap":false,"publish_time":1525021601200,"_cnpm_publish_time":1525021601200,"_cnpmcore_publish_time":"2021-12-16T18:30:49.605Z"}},"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/v2.0.0/index.js#L68\">`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","_attachments":{},"homepage":"https://github.com/sanctuary-js/sanctuary-show#readme","bugs":{"url":"https://github.com/sanctuary-js/sanctuary-show/issues"},"license":"MIT"}