{"_id":"@mapbox/shelf-pack","_rev":"263-6eed24edd2ea624748d4ca1ca4f5f981","name":"@mapbox/shelf-pack","description":"A 2D rectangular bin packing data structure that uses the Shelf Best Height Fit heuristic","dist-tags":{"latest":"3.2.0"},"versions":{"3.0.0":{"name":"@mapbox/shelf-pack","description":"A 2D rectangular bin packing data structure that uses the Shelf Best Height Fit heuristic","version":"3.0.0","main":"index.umd.js","jsnext:main":"index.js","license":"ISC","author":{"name":"Bryan Housel","email":"bryan@mapbox.com"},"repository":{"type":"git","url":"git+https://github.com/mapbox/shelf-pack.git"},"keywords":["bin packing","sprite"],"devDependencies":{"benchmark":"^2.1.0","bin-pack":"1.0.2","coveralls":"^2.11.12","documentation":"4.0.0-beta5","eslint":"^3.8.0","greenkeeper-postpublish":"^1.0.1","rollup":"0.41.4","tap":"^10.1.0"},"engines":{"node":">=4.0.0"},"scripts":{"bench":"npm run build && node bench/bench.js","build":"rollup -f umd -n ShelfPack index.js --no-indent --no-strict -o index.umd.js","docs":"documentation build index.js --lint --github --format html --output docs/","lint":"eslint index.js test/ bench/","test":"npm run build && npm run lint && tap --cov test/*.js","postpublish":"greenkeeper-postpublish"},"gitHead":"685083057b15f4e9dd26b7ee631d98ee66dadc11","bugs":{"url":"https://github.com/mapbox/shelf-pack/issues"},"homepage":"https://github.com/mapbox/shelf-pack#readme","_id":"@mapbox/shelf-pack@3.0.0","_shasum":"44e284c8336eeda1e9dbbb1d61954c70e26e5766","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.7.0","_npmUser":{"name":"bhousel","email":"bryan@mapbox.com"},"dist":{"shasum":"44e284c8336eeda1e9dbbb1d61954c70e26e5766","tarball":"https://registry.npmjs.org/@mapbox/shelf-pack/-/shelf-pack-3.0.0.tgz","integrity":"sha512-zNg5cvVoLx9zigv6w0OTCxoB06b0bq7ozHU/+qW+XUsHW3akYRCvYS26ZTCxec3Ca0pIdQ0ApPZMIS0vI0v4cQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDNOZKCIyvP1lrol3bkceeG7CyTxmiBWcXGlFZdu5wuYgIhANlBmlckN1WBk/33lxt8gWQpoU/gs3fI8r9vQLaOP2hg"}]},"maintainers":[{"name":"bhousel","email":"bryan@mapbox.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/shelf-pack-3.0.0.tgz_1486960752384_0.3332601219881326"},"directories":{}},"3.1.0":{"name":"@mapbox/shelf-pack","description":"A 2D rectangular bin packing data structure that uses the Shelf Best Height Fit heuristic","version":"3.1.0","main":"index.umd.js","jsnext:main":"index.js","license":"ISC","author":{"name":"Bryan Housel","email":"bryan@mapbox.com"},"repository":{"type":"git","url":"git+https://github.com/mapbox/shelf-pack.git"},"keywords":["bin packing","sprite"],"devDependencies":{"benchmark":"^2.1.0","bin-pack":"1.0.2","coveralls":"^2.11.12","documentation":"4.0.0-beta5","eslint":"^3.8.0","rollup":"0.41.4","tap":"^10.1.0"},"engines":{"node":">=4.0.0"},"scripts":{"bench":"npm run build && node bench/bench.js","build":"rollup -f umd -n ShelfPack index.js --no-indent --no-strict -o index.umd.js","docs":"documentation build index.js --lint --github --format html --output docs/","lint":"eslint index.js test/ bench/","test":"npm run build && npm run lint && tap --cov test/*.js"},"gitHead":"0df4c218bfef9ba059012e83a45f6418d566366c","bugs":{"url":"https://github.com/mapbox/shelf-pack/issues"},"homepage":"https://github.com/mapbox/shelf-pack#readme","_id":"@mapbox/shelf-pack@3.1.0","_shasum":"1edea9c0bf6715b217171ba60646c201af520f6a","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.7.0","_npmUser":{"name":"bhousel","email":"bryan@mapbox.com"},"dist":{"shasum":"1edea9c0bf6715b217171ba60646c201af520f6a","tarball":"https://registry.npmjs.org/@mapbox/shelf-pack/-/shelf-pack-3.1.0.tgz","integrity":"sha512-4ZzgSGi52fPTRDyjbwsOal4zBXw4Xbq3BTeAnXOQRCXsS5q49wAXMOp1sHK1sDEhL2KNHef3rSnJD4c3e0o/rw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDNUV+GuYylePwoGH0Y6ZyfI6hmwPKl4al+CWZnRairwQIhAPYzVhw6KEa7jQYTmcmdKf9st4gc7M4qrZsseZ57+a0f"}]},"maintainers":[{"email":"dave.prukop@mapbox.com","name":"d-prukop"},{"email":"lizzie.gooding@mapbox.com","name":"lizziegooding"},{"email":"mark.misener@mapbox.com","name":"markmisener"},{"email":"nick.italiano@mapbox.com","name":"nickitaliano"},{"email":"tara.adiseshan@gmail.com","name":"taziam"},{"email":"eli.fitch.prof+npm@gmail.com","name":"elifitch"},{"email":"nadia.barbosa@mapbox.com","name":"captainbarbosa-mbx"},{"email":"cameron@mapbox.com","name":"cammace"},{"email":"bruno@mapbox.com","name":"brunoabinader"},{"email":"langston.smith@mapbox.com","name":"langstonsmith"},{"email":"rafa@mapbox.com","name":"geografa"},{"email":"mxn@1ec5.org","name":"1ec5"},{"email":"liz.shigetoshi@mapbox.com","name":"lshig"},{"email":"hello@johnfurrow.com","name":"johnfurrow"},{"email":"andrea.delrio@mapbox.com","name":"aaaandrea"},{"email":"ali@mapbox.com","name":"alianthes"},{"email":"ann.millspaugh@gmail.com","name":"millzpaugh"},{"email":"hello@franka.tech","name":"franka"},{"email":"charlie@mapbox.com","name":"charloyd"},{"email":"julianne@mapbox.com","name":"juliannebg"},{"email":"dthompson@gmail.com","name":"dthompson"},{"email":"eric.alessandrini@mapbox.com","name":"ericdeveloper"},{"email":"jayana.charles@mapbox.com","name":"jayana"},{"email":"christopher.cailleaux@gmail.com","name":"chriscx"},{"email":"poornima@mapbox.com","name":"poornibadrinath"},{"email":"bersabel.tadesse@mapbox.com","name":"brsbl"},{"email":"mallorywood413@gmail.com","name":"mal-wood"},{"email":"luis@mapbox.com","name":"luiswalter"},{"email":"pilar@mapbox.com","name":"piligab"},{"email":"galia@mapbox.com","name":"yurasi"},{"email":"matt.gosline@mapbox.com","name":"matt.gosline"},{"email":"kelly.young@mapbox.com","name":"kellyoung"},{"email":"mully@mapbox.com","name":"zmully"},{"email":"mikel@groundtruth.in","name":"mikelmaron"},{"email":"danpat@danpat.net","name":"danpat"},{"email":"macro.shen@mapbox.com","name":"macro-shen"},{"email":"asheemm@gmail.com","name":"asheemmamoowala"},{"email":"john.sylak-glassman@mapbox.com","name":"jcsg"},{"email":"michael@mapbox.com","name":"michaelsteffen"},{"email":"aj@mapbox.com","name":"ajashton"},{"email":"devin.boyer@mapbox.com","name":"drboyer"},{"email":"andrey@mapbox.com","name":"andygol"},{"email":"flippmoke@gmail.com","name":"flippmoke"},{"email":"safonov.ilya@gmail.com","name":"ilyasaf"},{"email":"denis.koronchik@gmail.com","name":"deniskoronchik"},{"email":"peterqliu@gmail.com","name":"peterqliu"},{"email":"rasagy@mapbox.com","name":"rasagy"},{"email":"chethan@mapbox.com","name":"chetangowda"},{"email":"upendra@mapbox.com","name":"upendrayadav"},{"email":"cesar@mapbox.com","name":"calfarome"},{"email":"pavel@mapbox.com","name":"ridixcr"},{"email":"olivia.brundage@mapbox.com","name":"oliikit"},{"email":"aileen.s.rowan@gmail.com","name":"allierowan"},{"email":"richman@mapbox.com","name":"richrico"},{"email":"danny@mapbox.com","name":"dannykath"},{"email":"eliane@mapbox.com","name":"samely"},{"email":"nikinfour@gmail.com","name":"nikhilprabhakar"},{"email":"gokul.ganesan@mapbox.com","name":"fa7c0n"},{"email":"blannon@gmail.com","name":"boblannon"},{"email":"sean@mapbox.com","name":"sgillies"},{"email":"me@lukasmartinelli.ch","name":"lukasmartinelli"},{"email":"krishna@mapbox.com","name":"nammala"},{"email":"lindsay@mapbox.com","name":"lndsay"},{"email":"vestibule@anandthakker.net","name":"anandthakker"},{"email":"chris.loer@mapbox.com","name":"chrisloer"},{"email":"0o3ko0@gmail.com","name":"kepta"},{"email":"sam.kronick@mapbox.com","name":"kronick"},{"email":"manohar@mapbox.com","name":"manoharuss"},{"email":"alex.parlato@mapbox.com","name":"aparlato"},{"email":"yunjie.li@mapbox.com","name":"yunjieli"},{"email":"bharata+npm@mapbox.com","name":"bsrinivasa"},{"email":"aarthy@mapbox.com","name":"aarthykc"},{"email":"dane@mapbox.com","name":"springmeyer"},{"email":"dana.sulit@mapbox.com","name":"dasulit"},{"email":"emmanuel.sambale@gmail.com","name":"maning"},{"email":"miles.sackler@mapbox.com","name":"miles-dev"},{"email":"agafonkin@gmail.com","name":"mourner"},{"email":"hello@chau-nguyen.de","name":"chaupow"},{"email":"michael.krasnyk@gmail.com","name":"oxidase"},{"email":"r.ragupathy85@gmail.com","name":"rumc"},{"email":"vincent.sarago@mapbox.com","name":"vincents"},{"email":"tony.chen@mapbox.com","name":"tony-cj"},{"email":"arun.planemad@gmail.com","name":"planemad"},{"email":"patrick@mapbox.com","name":"themarex"},{"email":"laurier@mapbox.com","name":"l-r"},{"email":"alice@mapbox.com","name":"aliceykuo"},{"email":"ansis.brammanis@gmail.com","name":"ansis"},{"email":"oindrila.gupta92@gmail.com","name":"oini"},{"email":"virginia@mapbox.com","name":"virginiayung"},{"email":"karito@mapbox.com","name":"karitotp"},{"email":"srividyabharadwaj26@gmail.com","name":"srividyacb"},{"email":"perry@mapbox.com","name":"perrygeo"},{"email":"colleen.mcginnis@mapbox.com","name":"colleenmcginnis"},{"email":"nat@mapbox.com","name":"natslaughter"},{"email":"nick.cordella@mapbox.com","name":"nickcordella"},{"email":"benjamin@mapbox.com","name":"benjamintd"},{"email":"fischer@mapbox.com","name":"enf"},{"email":"kai@mapbox.com","name":"kaibot3000"},{"email":"paul@mapbox.com","name":"pdgoodman"},{"email":"max@mapbox.com","name":"msirenko"},{"email":"abhishek@mapbox.com","name":"saikia.abhishek"},{"email":"jothirnadh@mapbox.com","name":"jothirnadh"},{"email":"ryan.baumann@mapbox.com","name":"ryan-baumann"},{"email":"dan@mapbox.com","name":"danswick"},{"email":"lily@mapbox.com","name":"lily-chai"},{"email":"amisha@mapbox.com","name":"amishas157"},{"email":"kara.e.mahoney@gmail.com","name":"k-mahoney"},{"email":"bhargav.kowshik@gmail.com","name":"bkowshik"},{"email":"alinapaz@gmail.com","name":"alinapaz"},{"email":"damon@mapbox.com","name":"dnomadb"},{"email":"lyzi@mapbox.com","name":"lyzidiamond"},{"email":"spam@freenerd.de","name":"freenerd"},{"email":"carol@mapbox.com","name":"gretacb"},{"email":"mayaqgao@gmail.com","name":"mayaqgao"},{"email":"camilla@mapbox.com","name":"camillacaros"},{"email":"saman@mapbox.com","name":"samanbb"},{"email":"bryan@mapbox.com","name":"bhousel"},{"email":"daniel+npm@trvx.org","name":"danieljh"},{"email":"decorah@mapbox.com","name":"katydecorah"},{"email":"ajith@mapbox.com","name":"ajithranka"},{"email":"pratik@mapbox.com","name":"pratikyadav"},{"email":"morgan.herlocker@gmail.com","name":"morganherlocker"},{"email":"hi@jacquestardie.org","name":"jacquestardie"},{"email":"mollylloyd@gmail.com","name":"mollymerp"},{"email":"john.firebaugh@gmail.com","name":"jfirebaugh"},{"email":"tim.channell@gmail.com","name":"tcql"},{"email":"ruben@mapbox.com","name":"rub21"},{"email":"mail@kkaefer.com","name":"kkaefer"},{"email":"brendan@mapbox.com","name":"brendanmcfarland"},{"email":"moritz@mapbox.com","name":"mokob"},{"email":"karen@mapbox.com","name":"karenzshea"},{"email":"david.dave.clark@gmail.com","name":"davidtheclark"},{"email":"amyleewalton@gmail.com","name":"amyleew"},{"email":"ian.villeda@gmail.com","name":"ian29"},{"email":"nicki@mapbox.com","name":"nickidlugash"},{"email":"jake@jakepruitt.com","name":"jrpruit1"},{"email":"mcwhittemore@gmail.com","name":"mcwhittemore"},{"email":"siyu.song@gmail.com","name":"isiyu"},{"email":"ghoshkaj@gmail.com","name":"ghoshkaj"},{"email":"ulsh@mapbox.com","name":"alulsh"},{"email":"emily@mapbox.com","name":"emilymcafee"},{"email":"sam@mapbox.com","name":"mapsam"},{"email":"alex@mapbox.com","name":"lxbarth"},{"email":"will@mapbox.com","name":"willwhite"},{"email":"sanjay@mapbox.com","name":"batpad"},{"email":"sajjadkm@gmail.com","name":"geohacker"},{"email":"aruna@mapbox.com","name":"arunasank"},{"email":"kai@mapbox.com","name":"kaidalgleish"},{"email":"matt@mattficke.com","name":"mattficke"},{"email":"andrew@mapbox.com","name":"apendleton"},{"email":"nicholas.ingalls@gmail.com","name":"ingalls"},{"email":"thomas.j.lee@gmail.com","name":"sbma44"},{"email":"dubois@mapbox.com","name":"emilymdubois"},{"email":"young@mapbox.com","name":"yhahn"},{"email":"ian@mapbox.com","name":"ianshward"},{"email":"jeff@miccolis.net","name":"miccolis"},{"email":"ryan.clark.j@gmail.com","name":"rclark"},{"email":"lauren@mapbox.com","name":"lbud"},{"email":"bobby@mapbox.com","name":"bsudekum"},{"email":"tristen.brown@gmail.com","name":"tristen"},{"email":"accounts@mapbox.com","name":"mapbox-admin"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/shelf-pack-3.1.0.tgz_1503637672176_0.6718796011991799"},"directories":{}},"3.2.0":{"name":"@mapbox/shelf-pack","description":"A 2D rectangular bin packing data structure that uses the Shelf Best Height Fit heuristic","version":"3.2.0","main":"index.js","module":"index.mjs","license":"ISC","author":{"name":"Bryan Housel","email":"bryan@mapbox.com"},"repository":{"type":"git","url":"git+https://github.com/mapbox/shelf-pack.git"},"keywords":["bin packing","sprite"],"devDependencies":{"benchmark":"^2.1.0","bin-pack":"1.0.2","coveralls":"^3.0.0","documentation":"4.0.0-beta5","eslint":"^5.0.0","rollup":"0.60.0","tap":"^12.0.0"},"engines":{"node":">=6.0.0"},"scripts":{"bench":"npm run build && node bench/bench.js","build":"rollup -f umd -n ShelfPack index.mjs --no-indent --no-strict -o index.js","docs":"documentation build index.mjs --lint --github --format html --output docs/","lint":"eslint index.mjs test/ bench/","test":"npm run build && npm run lint && tap --cov test/*.js"},"gitHead":"aff2193ba439937aedaf38f97f2f26a8bc133453","bugs":{"url":"https://github.com/mapbox/shelf-pack/issues"},"homepage":"https://github.com/mapbox/shelf-pack#readme","_id":"@mapbox/shelf-pack@3.2.0","_npmVersion":"6.1.0","_nodeVersion":"6.7.0","_npmUser":{"name":"mapbox-npm-04","email":"accounts+npmjs-04@mapbox.com"},"dist":{"integrity":"sha512-dyQxe6ukILV6qaEvxoKCIwhblgRjYp1ZGlClo4xvfbmxzFO5LYu7Tnrg2AZrRgN7VsSragsGcNjzUe9kCdKHYQ==","shasum":"df3630ecce8c042817c9a365b88078412963de64","tarball":"https://registry.npmjs.org/@mapbox/shelf-pack/-/shelf-pack-3.2.0.tgz","fileCount":9,"unpackedSize":40618,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbSLU5CRA9TVsSAnZWagAAM20P/3APEbVp6b8TgVNYhFLi\nVOlH3GSv0vseD1qYdepH6wLQ14pNFaCdufr745rJ9WKei60b0Bj3uKHJ4cZU\naJ7Sb+TljTUYyz1DurYm/r0Yk52Gy3Xg2D+lIPUgsrZTfvihExrHBkJx1ZUh\negfcKaLFV9SH4rA0wY1iRSVoVstHLtBYMukoby92F97FzuOjaNwnHB20J1JZ\nmuWuFSMZvYbCz4ELJlX/9le9hAHTUe2WRovG0vf309QkL1TuQRtQ+iPuiv8M\nsxxbUzKSeWJ7NauwKLynkfUMbeUcaycRzDoOs6wgjEQnD+/bCz7HUUkQwt6V\njqh3OcSntJMle0KqUfs4ruTn9Bk+HEvwHL2h6ajXuqIlpETNKdE7gnd1B0YS\n3dvYU8plvM+lktmGivy9HoVAkd4go9LvbaUliCOWWqSdwEQwh1jKXEwlH64m\n8L48aId4OXnFcYP7j7c16Q85EnMKnoRFVJD8dbu9CdQw2cE8NVT7uk9fatGn\n4KbsFTIlsVTT2X72bTvEZubwWt57ctFlw6eQqbkhwrvFcrXqIwKige/geK//\nTu5vDjjYpIMvL0KlAq68TsYr0TTDdJ+ZhdM5EJeutuc64QxCzHKH7lL8DJAP\n8plNylFNStggeTPFYco8SaAKbUNlljwtLfLm0ZSITR5XPs665/yAEdwYhOHL\nA9g7\r\n=TcHS\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEFBvgZcD9f9Gfs3JHcpCIrLdAJhLSDYkV3L5cJIyWdkAiAW1l99qGAvFCBCxAcRTcHI5rkyTGfSfqvj/X41jTyoZQ=="}]},"maintainers":[{"email":"accounts@mapbox.com","name":"mapbox-admin"},{"email":"accounts+npmjs@mapbox.com","name":"mapbox-npm"},{"email":"accounts+npmjs-01@mapbox.com","name":"mapbox-npm-01"},{"email":"accounts+npmjs-02@mapbox.com","name":"mapbox-npm-02"},{"email":"accounts+npmjs-03@mapbox.com","name":"mapbox-npm-03"},{"email":"accounts+npmjs-04@mapbox.com","name":"mapbox-npm-04"},{"email":"accounts+npmjs-05@mapbox.com","name":"mapbox-npm-05"},{"email":"accounts+npmjs-06@mapbox.com","name":"mapbox-npm-06"},{"email":"accounts+npmjs-07@mapbox.com","name":"mapbox-npm-07"},{"email":"accounts+npmjs-08@mapbox.com","name":"mapbox-npm-08"},{"email":"accounts+npmjs-09@mapbox.com","name":"mapbox-npm-09"},{"email":"accounts+npmjs-advanced-actions@mapbox.com","name":"mapbox-npm-advanced-actions"},{"email":"accounts+npmjs-npm-ci@mapbox.com","name":"mapbox-npm-ci"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/shelf-pack_3.2.0_1531491640990_0.2681459632204286"},"_hasShrinkwrap":false}},"readme":"[![npm version](https://badge.fury.io/js/%40mapbox%2Fshelf-pack.svg)](https://badge.fury.io/js/%40mapbox%2Fshelf-pack)\n[![Build Status](https://secure.travis-ci.org/mapbox/shelf-pack.svg)](http://travis-ci.org/mapbox/shelf-pack)\n[![Coverage Status](https://coveralls.io/repos/github/mapbox/shelf-pack/badge.svg?branch=master)](https://coveralls.io/github/mapbox/shelf-pack?branch=master)\n\n## shelf-pack\n\nA 2D rectangular [bin packing](https://en.wikipedia.org/wiki/Bin_packing_problem)\ndata structure that uses the Shelf Best Height Fit heuristic.\n\n\n### What is it?\n\n`shelf-pack` is a library for packing little rectangles into a big rectangle.  This sounds simple enough,\nbut finding an optimal packing is a problem with [NP-Complete](https://en.wikipedia.org/wiki/NP-completeness)\ncomplexity.  One useful application of bin packing is to assemble icons or glyphs into a sprite texture.\n\nThere are many ways to approach the bin packing problem, but `shelf-pack` uses the Shelf Best\nHeight Fit heuristic.  It works by dividing the total space into \"shelves\", each with a certain height.\nThe allocator packs rectangles onto whichever shelf minimizes the amount of wasted vertical space.\n\n`shelf-pack` is simple, fast, and works best when the rectangles have similar heights (icons and glyphs\nare like this).  It is not a generalized bin packer, and can potentially waste a lot of space if the\nrectangles vary significantly in height.\n\n\n### How fast is it?\n\nReally fast!  `shelf-pack` is several orders of magnitude faster than the more general\n[`bin-pack`](https://www.npmjs.com/package/bin-pack) library.\n\n```bash\n> npm run bench\n\nShelfPack single allocate fixed size bins x 1,610 ops/sec ±1.21% (90 runs sampled)\nShelfPack single allocate random width bins x 1,475 ops/sec ±1.00% (89 runs sampled)\nShelfPack single allocate random height bins x 1,458 ops/sec ±1.00% (90 runs sampled)\nShelfPack single allocate random height and width bins x 1,346 ops/sec ±0.96% (89 runs sampled)\nShelfPack batch allocate fixed size bins x 1,522 ops/sec ±1.06% (86 runs sampled)\nShelfPack batch allocate random width bins x 1,427 ops/sec ±1.06% (89 runs sampled)\nShelfPack batch allocate random height bins x 1,350 ops/sec ±1.63% (90 runs sampled)\nShelfPack batch allocate random height and width bins x 1,257 ops/sec ±1.02% (89 runs sampled)\nBinPack batch allocate fixed size bins x 2.21 ops/sec ±6.60% (10 runs sampled)\nBinPack batch allocate random width bins x 0.50 ops/sec ±2.25% (6 runs sampled)\nBinPack batch allocate random height bins x 0.51 ops/sec ±1.97% (6 runs sampled)\nBinPack batch allocate random height and width bins x 0.51 ops/sec ±1.37% (6 runs sampled)\n```\n\n\n### Usage\n\n#### Basic Usage\n\n```js\nvar ShelfPack = require('@mapbox/shelf-pack');\n\n// Initialize the sprite with a width and height..\nvar sprite = new ShelfPack(64, 64);\n\n// Pack bins one at a time..\nfor (var i = 0; i < 5; i++) {\n    // packOne() accepts parameters: `width`, `height`, `id`\n    // and returns a single allocated Bin object..\n    // `id` is optional - if you skip it, shelf-pack will make up a number for you..\n    // (Protip: numeric ids are much faster than string ids)\n\n    var bin = sprite.packOne(32, 32);\n    console.log(bin || 'out of space');\n}\n\n/* output:\nBin { id: 1, x: 0, y: 0, w: 32, h: 32, maxw: 32, maxh: 32, refcount: 1 }\nBin { id: 2, x: 32, y: 0, w: 32, h: 32, maxw: 32, maxh: 32, refcount: 1 }\nBin { id: 3, x: 0, y: 32, w: 32, h: 32, maxw: 32, maxh: 32, refcount: 1 }\nBin { id: 4, x: 32, y: 32, w: 32, h: 32, maxw: 32, maxh: 32, refcount: 1 }\nout of space\n*/\n\n// Clear sprite and start over..\nsprite.clear();\n\n// Or, resize sprite by passing larger dimensions..\nsprite.resize(128, 128);   // width, height\n\n```\n\n\n#### Batch packing\n\n```js\nvar ShelfPack = require('@mapbox/shelf-pack');\n\n// If you don't want to think about the size of the sprite,\n// the `autoResize` option will allow it to grow as needed..\nvar sprite = new ShelfPack(10, 10, { autoResize: true });\n\n// Bins can be allocated in batches..\n// Each requested bin should have `w`, `h` (or `width`, `height`) properties..\nvar requests = [\n    { id: 'a', width: 10, height: 10 },\n    { id: 'b', width: 10, height: 12 },\n    { id: 'c', w: 10, h: 12 },\n    { id: 'd', w: 10, h: 10 }\n];\n\n// pack() returns an Array of packed Bin objects..\nvar results = sprite.pack(requests);\n\nresults.forEach(function(bin) {\n    console.log(bin);\n});\n\n/* output:\nBin { id: 'a', x: 0, y: 0, w: 10, h: 10, maxw: 10, maxh: 10, refcount: 1 }\nBin { id: 'b', x: 0, y: 10, w: 10, h: 12, maxw: 10, maxh: 12, refcount: 1 }\nBin { id: 'c', x: 10, y: 10, w: 10, h: 12, maxw: 10, maxh: 12, refcount: 1 }\nBin { id: 'd', x: 10, y: 0, w: 10, h: 10, maxw: 10, maxh: 10, refcount: 1 }\n*/\n\n// If you don't mind letting ShelfPack modify your objects,\n// the `inPlace` option will decorate your bin objects with `x` and `y` properties.\n// Fancy!\nvar myBins = [\n    { id: 'e', width: 12, height: 24 },\n    { id: 'f', width: 12, height: 12 },\n    { id: 'g', w: 10, h: 10 }\n];\n\nsprite.pack(myBins, { inPlace: true });\nmyBins.forEach(function(bin) {\n    console.log(bin);\n});\n\n/* output:\n{ id: 'e', width: 12, height: 24, x: 0, y: 22 }\n{ id: 'f', width: 12, height: 12, x: 20, y: 10 }\n{ id: 'g', w: 10, h: 10, x: 20, y: 0 }\n*/\n\n```\n\n#### Reference Counting\n\n```js\nvar ShelfPack = require('@mapbox/shelf-pack');\n\n// Initialize the sprite with a width and height..\nvar sprite = new ShelfPack(64, 64);\n\n// Allocated bins are automatically reference counted.\n// They start out having a refcount of 1.\n[100, 101, 102].forEach(function(id) {\n    var bin = sprite.packOne(16, 16, id);\n    console.log(bin);\n});\n\n/* output:\nBin { id: 100, x: 0, y: 0, w: 16, h: 16, maxw: 16, maxh: 16, refcount: 1 }\nBin { id: 101, x: 16, y: 0, w: 16, h: 16, maxw: 16, maxh: 16, refcount: 1 }\nBin { id: 102, x: 32, y: 0, w: 16, h: 16, maxw: 16, maxh: 16, refcount: 1 }\n*/\n\n// If you try to pack the same id again, shelf-pack will not re-pack it.\n// Instead, it will increment the reference count automatically..\nvar bin102 = sprite.packOne(16, 16, 102);\nconsole.log(bin102);\n\n/* output:\nBin { id: 102, x: 32, y: 0, w: 16, h: 16, maxw: 16, maxh: 16, refcount: 2 }\n*/\n\n// You can also manually increment the reference count..\nvar bin101 = sprite.getBin(101);\nsprite.ref(bin101);\nconsole.log(bin101);\n\n/* output:\nBin { id: 101, x: 16, y: 0, w: 16, h: 16, maxw: 16, maxh: 16, refcount: 2 }\n*/\n\n// ...and decrement it!\nvar bin100 = sprite.getBin(100);\nsprite.unref(bin100);\nconsole.log(bin100);\n\n/* output:\nBin { id: 100, x: 0, y: 0, w: 16, h: 16, maxw: 16, maxh: 16, refcount: 0 }\n*/\n\n// Bins with a refcount of 0 are considered free space.\n// Next time a bin is packed, shelf-back tries to reuse free space first.\n// See how Bin 103 gets allocated at [0,0] - Bin 100's old spot!\nvar bin103 = sprite.packOne(16, 15, 103);\nconsole.log(bin103);\n\n/* output:\nBin { id: 103, x: 0, y: 0, w: 16, h: 15, maxw: 16, maxh: 16, refcount: 1 }\n*/\n\n// Bin 103 may be smaller (16x15) but it knows 16x16 was its original size.\n// If that space becomes free again, a 16x16 bin will still fit there.\nsprite.unref(bin103)\nvar bin104 = sprite.packOne(16, 16, 104);\nconsole.log(bin104);\n\n/* output:\nBin { id: 104, x: 0, y: 0, w: 16, h: 16, maxw: 16, maxh: 16, refcount: 1 }\n*/\n\n```\n\n\n### Documentation\n\nComplete API documentation is here:  http://mapbox.github.io/shelf-pack/\n\n\n### See also\n\nJ. Jylänky, \"A Thousand Ways to Pack the Bin - A Practical\nApproach to Two-Dimensional Rectangle Bin Packing,\"\nhttp://clb.demon.fi/files/RectangleBinPack.pdf, 2010\n","maintainers":[{"email":"yannick.meeus+npm+production+ci@mapbox.com","name":"mbx-npm-ci-production"},{"email":"yannick.meeus+npm+staging+ci@mapbox.com","name":"mbx-npm-ci-staging"},{"email":"yannick.meeus+npm+prod+advanced+actions@mapbox.com","name":"mbx-npm-advanced-actions-production"},{"email":"yannick.meeus+npm+staging+advanced+actions@mapbox.com","name":"mbx-npm-advanced-actions-staging"},{"email":"yannick.meeus+npm+prod+09@mapbox.com","name":"mbx-npm-09-production"},{"email":"yannick.meeus+npm+prod+08@mapbox.com","name":"mbx-npm-08-production"},{"email":"yannick.meeus+npm+prod+07@mapbox.com","name":"mbx-npm-07-production"},{"email":"yannick.meeus+npm+prod+06@mapbox.com","name":"mbx-npm-06-production"},{"email":"yannick.meeus+npm+prod+05@mapbox.com","name":"mbx-npm-05-production"},{"email":"yannick.meeus+npm+prod+04@mapbox.com","name":"mbx-npm-04-production"},{"email":"yannick.meeus+npm+prod+03@mapbox.com","name":"mbx-npm-03-production"},{"email":"yannick.meeus+npm+prod+02@mapbox.com","name":"mbx-npm-02-production"},{"email":"yannick.meeus+npm+prod+01@mapbox.com","name":"mbx-npm-01-production"},{"email":"yannick.meeus@mapbox.com","name":"mbx-npm-02-staging"},{"email":"accounts+npmjs-01@mapbox.com","name":"mapbox-npm-01"},{"email":"accounts+npmjs-02@mapbox.com","name":"mapbox-npm-02"},{"email":"accounts+npmjs-07@mapbox.com","name":"mapbox-npm-07"},{"email":"accounts+npmjs-03@mapbox.com","name":"mapbox-npm-03"},{"email":"accounts+npmjs-04@mapbox.com","name":"mapbox-npm-04"},{"email":"accounts+npmjs-09@mapbox.com","name":"mapbox-npm-09"},{"email":"accounts+npmjs-05@mapbox.com","name":"mapbox-npm-05"},{"email":"accounts+npmjs-06@mapbox.com","name":"mapbox-npm-06"},{"email":"accounts+npmjs-08@mapbox.com","name":"mapbox-npm-08"},{"email":"accounts+npmjs-advanced-actions@mapbox.com","name":"mapbox-npm-advanced-actions"},{"email":"accounts+npmjs-npm-ci@mapbox.com","name":"mapbox-npm-ci"},{"email":"accounts+npmjs@mapbox.com","name":"mapbox-npm"},{"email":"accounts@mapbox.com","name":"mapbox-admin"},{"email":"accounts+npm-mapbox-machine-user@mapbox.com","name":"mapbox-machine-user"}],"time":{"modified":"2023-01-12T12:36:25.538Z","created":"2017-02-13T04:39:14.361Z","3.0.0":"2017-02-13T04:39:14.361Z","3.1.0":"2017-08-25T05:07:53.296Z","3.2.0":"2018-07-13T14:20:41.104Z"},"homepage":"https://github.com/mapbox/shelf-pack#readme","keywords":["bin packing","sprite"],"repository":{"type":"git","url":"git+https://github.com/mapbox/shelf-pack.git"},"author":{"name":"Bryan Housel","email":"bryan@mapbox.com"},"bugs":{"url":"https://github.com/mapbox/shelf-pack/issues"},"license":"ISC","readmeFilename":"README.md"}