{"_id":"glsl-token-descope","_rev":"25-2b79c9c364f25e6292079e0a14823979","name":"glsl-token-descope","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"glsl-token-descope","version":"1.0.0","keywords":["ecosystem:stackgl"],"author":{"url":"http://hughsk.io/","name":"Hugh Kennedy","email":"hughskennedy@gmail.com"},"license":"MIT","_id":"glsl-token-descope@1.0.0","maintainers":[{"name":"hughsk","email":"hughskennedy@gmail.com"}],"homepage":"https://github.com/stackgl/glsl-token-descope","bugs":{"url":"https://github.com/stackgl/glsl-token-descope/issues"},"dist":{"shasum":"815b3dab80758f463a29c98e08472f0707c03cfb","tarball":"https://registry.npmjs.org/glsl-token-descope/-/glsl-token-descope-1.0.0.tgz","integrity":"sha512-DgJMDOW5TYlOOQuuz5PSoY4z1ncgGC800OdCs12Z7T1h9PzJs2lsU6hALV11zpgdUKgA0TgI/orpSG1kqoNRUA==","signatures":[{"sig":"MEUCIFUnFeCzC8tUfY4IFvnNX4pa/LgzSj03KHo1sOOrG+uQAiEA8NYCtNjUx4kw94w99jT4zhHLi4RsD+o76lDy8c0GnHc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"815b3dab80758f463a29c98e08472f0707c03cfb","gitHead":"3313efc5cb6965c9ccc41e62975c1d85b82f2c2c","scripts":{"test":"node test/index.js | tap-spec","eyeball":"node test/eyeball.js"},"_npmUser":{"name":"hughsk","email":"hughskennedy@gmail.com"},"repository":{"url":"git://github.com/stackgl/glsl-token-descope.git","type":"git"},"_npmVersion":"2.1.16","description":"\"Descope\" an array of GLSL tokens such that they can be safely inlined alongside within another shader without causing any global variable conflicts.","directories":{},"_nodeVersion":"0.10.28","dependencies":{"glsl-token-depth":"^1.1.0","glsl-token-scope":"^1.1.0","glsl-token-properties":"^1.0.0","glsl-token-assignments":"^2.0.0"},"devDependencies":{"6to5":"^2.5.0","tape":"^3.0.3","chalk":"^0.5.1","tap-spec":"^2.1.2","glsl-tokenizer":"git://github.com/stackgl/glsl-tokenizer#2.0.0","glsl-token-string":"^1.0.0"}},"1.0.1":{"name":"glsl-token-descope","version":"1.0.1","keywords":["ecosystem:stackgl"],"author":{"url":"http://hughsk.io/","name":"Hugh Kennedy","email":"hughskennedy@gmail.com"},"license":"MIT","_id":"glsl-token-descope@1.0.1","maintainers":[{"name":"hughsk","email":"hughskennedy@gmail.com"}],"homepage":"https://github.com/stackgl/glsl-token-descope","bugs":{"url":"https://github.com/stackgl/glsl-token-descope/issues"},"dist":{"shasum":"4e39938e09e5384bb96323de7465e2021fd2785a","tarball":"https://registry.npmjs.org/glsl-token-descope/-/glsl-token-descope-1.0.1.tgz","integrity":"sha512-V+T0H/l++jaRsDP6e6+NSYS1vLrzDhpq2A9/lCI/zIPwhxTN5piDm1yBK6KVpAXDqnxDsxyO2+25qDBOCRH9uw==","signatures":[{"sig":"MEYCIQDkmf7ydZUGYnkvaOmwCL9CqppXY28WcGunHwy3nIQmPQIhANUrVUvOAbyD5CoC3+tUjb5bkwjdwa5cdXXX0qKOir7Y","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"4e39938e09e5384bb96323de7465e2021fd2785a","gitHead":"91af357acbea822f287554ccf71eaac91b6b43d6","scripts":{"test":"node test/index.js | tap-spec","eyeball":"node test/eyeball.js"},"_npmUser":{"name":"hughsk","email":"hughskennedy@gmail.com"},"repository":{"url":"git://github.com/stackgl/glsl-token-descope.git","type":"git"},"_npmVersion":"2.1.16","description":"\"Descope\" an array of GLSL tokens such that they can be safely inlined alongside within another shader without causing any global variable conflicts.","directories":{},"_nodeVersion":"0.10.28","dependencies":{"glsl-token-depth":"^1.1.0","glsl-token-scope":"^1.1.0","glsl-token-properties":"^1.0.0","glsl-token-assignments":"^2.0.0"},"devDependencies":{"6to5":"^2.5.0","tape":"^3.0.3","chalk":"^0.5.1","tap-spec":"^2.1.2","glsl-tokenizer":"git://github.com/stackgl/glsl-tokenizer#2.0.0","glsl-token-string":"^1.0.0"}},"1.0.2":{"name":"glsl-token-descope","version":"1.0.2","keywords":["ecosystem:stackgl"],"author":{"url":"http://hughsk.io/","name":"Hugh Kennedy","email":"hughskennedy@gmail.com"},"license":"MIT","_id":"glsl-token-descope@1.0.2","maintainers":[{"name":"hughsk","email":"hughskennedy@gmail.com"},{"name":"substack","email":"mail@substack.net"}],"homepage":"https://github.com/stackgl/glsl-token-descope","bugs":{"url":"https://github.com/stackgl/glsl-token-descope/issues"},"dist":{"shasum":"0fc90ab326186b82f597b2e77dc9e21efcd32076","tarball":"https://registry.npmjs.org/glsl-token-descope/-/glsl-token-descope-1.0.2.tgz","integrity":"sha512-kS2PTWkvi/YOeicVjXGgX5j7+8N7e56srNDEHDTVZ1dcESmbmpmgrnpjPcjxJjMxh56mSXYoFdZqb90gXkGjQw==","signatures":[{"sig":"MEUCIQDUK1Thqbi9bhscplMauEziC7YL6f7Jza5Q5/+C4TF9agIgUUnd0WeSNmB9oBKCjcoSnniE4c5saCE0N7F76tVf4nc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"0fc90ab326186b82f597b2e77dc9e21efcd32076","gitHead":"31673dcc087f308707a8d0e8cd6445dbb11554de","scripts":{"test":"node test/index.js | tap-spec","eyeball":"node test/eyeball.js"},"_npmUser":{"name":"hughsk","email":"hughskennedy@gmail.com"},"repository":{"url":"git://github.com/stackgl/glsl-token-descope.git","type":"git"},"_npmVersion":"2.5.0","description":"\"Descope\" an array of GLSL tokens such that they can be safely inlined alongside within another shader without causing any global variable conflicts.","directories":{},"_nodeVersion":"0.10.36","dependencies":{"glsl-token-depth":"^1.1.0","glsl-token-scope":"^1.1.0","glsl-token-properties":"^1.0.0","glsl-token-assignments":"^2.0.0"},"devDependencies":{"6to5":"^2.5.0","tape":"^3.0.3","chalk":"^0.5.1","tap-spec":"^2.1.2","glsl-tokenizer":"^2.0.0","glsl-token-string":"^1.0.0"}}},"time":{"created":"2015-01-04T23:22:32.836Z","modified":"2024-12-29T00:47:16.009Z","1.0.0":"2015-01-04T23:22:32.836Z","1.0.1":"2015-01-04T23:23:32.390Z","1.0.2":"2015-03-06T23:47:11.012Z"},"bugs":{"url":"https://github.com/stackgl/glsl-token-descope/issues"},"author":{"url":"http://hughsk.io/","name":"Hugh Kennedy","email":"hughskennedy@gmail.com"},"license":"MIT","homepage":"https://github.com/stackgl/glsl-token-descope","keywords":["ecosystem:stackgl"],"repository":{"url":"git://github.com/stackgl/glsl-token-descope.git","type":"git"},"description":"\"Descope\" an array of GLSL tokens such that they can be safely inlined alongside within another shader without causing any global variable conflicts.","maintainers":[{"email":"hughskennedy@gmail.com","name":"hughsk"},{"email":"mikolalysenko@gmail.com","name":"mikolalysenko"},{"email":"dave.des@gmail.com","name":"mattdesl"},{"email":"chris@neversaw.us","name":"chrisdickinson"},{"email":"javascript@yosh.is","name":"yoshuawuyts"},{"email":"me@mikkoh.com","name":"mikkoh"},{"email":"tatum.creative@gmail.com","name":"tatumcreative"},{"email":"wwwtyro@gmail.com","name":"wwwtyro"},{"email":"thibaut.seguy@gmail.com","name":"thibauts"},{"email":"post.ben.here@gmail.com","name":"bpostlethwaite"},{"email":"df.creative@gmail.com","name":"dfcreative"},{"email":"arnebackeric@gmail.com","name":"erkaman"},{"email":"renaudeau.gaetan@gmail.com","name":"gre"},{"email":"rsreusser@gmail.com","name":"rreusser"},{"email":"marcin.ignac@gmail.com","name":"vorg"},{"email":"arch.mojtaba.samimi@gmail.com","name":"archmoj"}],"readme":"# glsl-token-descope\n\n[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)\n\n\"Descope\" an array of GLSL tokens such that they can be safely inlined alongside\nwithin another shader without causing any global variable conflicts.\n\nUseful for modularising GLSL source files, e.g. as is done in\n[glslify](http://github.com/stackgl/glslify), but should be useful in other\ntools too.\n\nWritten with WebGL's GLSL syntax in mind – all the same, pull requests to\nsupport other variants would be much appreciated :)\n\n## Usage\n\n[![NPM](https://nodei.co/npm/glsl-token-descope.png)](https://nodei.co/npm/glsl-token-descope/)\n\n### `descope(tokens, [rename(name)])`\n\nTakes an array of GLSL `tokens` produced by\n[glsl-tokenizer](http://github.com/stackgl/glsl-tokenizer) and renames variables\nto avoid global conflicts by modifying their \"data\" property in-place.\n\nFor example:\n\n``` javascript\nvar tokenize  = require('glsl-tokenizer/string')\nvar descope   = require('glsl-token-descope')\nvar stringify = require('glsl-token-string')\n\nvar src = `\nprecision mediump float;\n\nuniform mat4  top1;\nuniform float top2;\n\nvoid main() {\n  float x = 1.0;\n  gl_FragColor = vec4(vec3(x), top2);\n}\n`.trim()\n\nvar tokens = tokenize(src)\n\nconsole.log(stringify(descope(tokens)))\n```\n\nWhich should rename `main`, `top1` and `top2` to result in this output:\n\n``` glsl\nprecision mediump float;\n\nuniform mat4  top1_0;\nuniform float top2_1;\n\nvoid main_2() {\n  float x = 1.0;\n  gl_FragColor = vec4(vec3(x), top2_1);\n}\n```\n\nOptionally, you may pass in a custom `rename` function as `descope`'s second\nargument to choose how you rename your variables. For example, adding a custom\n`rename` function to the previous function:\n\n``` javascript\ndescope(tokens, function(name) {\n  return 'a_' + name\n})\n```\n\nWould result in the following shader:\n\n``` glsl\nprecision mediump float;\n\nuniform mat4  a_top1;\nuniform float a_top2;\n\nvoid a_main() {\n  float x = 1.0;\n  gl_FragColor = vec4(vec3(x), a_top2);\n}\n```\n\n## See Also\n\n* [glslify](http://github.com/stackgl/glslify)\n* [glsl-token-scope](http://github.com/stackgl/glsl-token-scope)\n* [glsl-token-depth](http://github.com/stackgl/glsl-token-depth)\n* [glsl-token-properties](http://github.com/stackgl/glsl-token-properties)\n* [glsl-token-assignments](http://github.com/stackgl/glsl-token-assignments)\n* [glsl-token-string](http://github.com/stackgl/glsl-token-string)\n\n## License\n\nMIT. See [LICENSE.md](http://github.com/stackgl/glsl-token-descope/blob/master/LICENSE.md) for details.\n","readmeFilename":"README.md"}