{"_id":"u","_rev":"6-5105f8c2bb8afaede9415306c1838f63","name":"u","description":"A minimalist, functional utility library designed for embedding into another small program.","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"u","version":"0.1.0","description":"A minimalist, functional utility library designed for embedding into another small program.","keywords":["functional","util","client","browser","embedding","bootstrapper"],"homepage":"http://dsc.github.com/u.js/","author":{"name":"David Schoonover","email":"dsc@less.ly","url":"http://less.ly"},"main":"./u.js","dependencies":{},"repository":{"type":"git","url":"git://github.com/dsc/u.js.git"},"bugs":{"url":"http://github.com/dsc/u.js/issues"},"engine":{"node":">=0.4.0"},"license":"MIT","_npmUser":{"name":"dsc","email":"dsc@less.ly"},"_id":"u@0.1.0","devDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.105","_nodeVersion":"v0.6.2","_defaultsLoaded":true,"dist":{"shasum":"f5cc15d0063241e2c95004990fc4dd989bf1fcb3","tarball":"https://registry.npmjs.org/u/-/u-0.1.0.tgz","integrity":"sha512-johjpjhqy9UE97vjDFq8kW6F1777vIz0i+AZXzisbW6yn6Aa8iX3V7bW4W6GzI7sbw3HjYuvN2yMx2k6QwX5ng==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEx3vYMUSKtaTIPvMStZdGEt8fxPRRwHTHMbFujPiCALAiEAngxfFB0ViIyCRwhOQzKN3VuWbjVagd/3NksMC7s0d0g="}]},"maintainers":[{"name":"dsc","email":"dsc@less.ly"}]}},"readme":"# u.js &mdash; minimalist utilities\n\n`u.js` is a minimalist, functional utility library designed for embedding into another small program.\n\n * Collection utilities that work on both Arrays and Objects (`reduce`, `map`)\n * Copying/extending Objects\n * Binding function scope\n * Serializing and deserializing query-string KV pairs\n * Optional polyfills in `future.js` for the most important JS features \n   missing from older browsers (e.g., `Array.map()`, `Object.keys()`)\n\nThat's it.<sup><a name=\"fn1_link\" href=\"#fn1\">1</a></sup> `u.js` has no dependencies and works in \nany browser. The code has seen extensive production use, but the tests were part of a bigger \nproject and have not yet been ported.\n\n\n## Why?\n\n`u.js` is ideal for building a **bootstrapper**. Several of my projects have been embeddable tools.\nWhen your code is going to run in hostile territory, versioning is especially important, but it\nrequires some way to get your versioned code on the page in the first place: a bootstrapper.\n\nA tiny bootstrapper gives your users the flexibility to choose a version, but gives you the power to\nsmooth over implementation assumptions (like changing configuration parameters, embedding-code, or\nthe inevitable bug pasted onto someone's page). So I needed something tiny primarily to parse\nquerystring values and work with collections. It had to come prior to the main program, as the\nprogram version could be overriden by configuration!\n\n\n## API\n\n### u.reduce(o, fn, [acc], [cxt=o])\n\nAs `Array.prototype.reduce()`, but for both Object and Arrays.\n\nInvokes `acc = fn.call(cxt, acc, v, k, o)` for each value in the collection, returning the final\nvalue of the accumulator. For Arrays, `k` will be the index.\n\n\n### u.map(o, fn, cxt=o)\n\nAs `Array.prototype.map()`, but for both Object and Arrays.\n\nInvokes `fn.call(cxt, v, k, o)` for each value in the collection, returning a new collection with\nthe mapped values. (The collection will be an Object or Array based on the type of the input\ncollection.)\n\n\n### u.extend(target, ...donors) -> target\n\nCopies all keys from each `donor` onto the `target` object, and then returns it.\n\n\n### u.bind(fn, context, ...args) -> Function\n\nStub for `Function.prototype.bind()`: returns a function `(...more_args)` that when invoked, \ncalls the original function with the supplied context and arguments from both invocations \nconcatenated together:\n\n`fn.apply( context, args.concat(more_args) )`\n\n\n### u.isArray(o) -> Boolean\n\nReturns whether the input object is an Array; calls `Array.isArray(o)` if it exists, and a polyfill\notherwise.\n\n\n### u.trim(s) -> String\n\nReturns the string with leading and trailing whitespace removed.\n\n\n### u.toKV(o, delimiter='&') -> String\n\nSerializes an object into a string of \"form-encoded\" key-value pairs, applying one layer of\nURL-encoding.\n\n\n### u.fromKV(q, delimiter='&') -> Object\n\nDeserializes \"form-encoded\" key-value pairs (removing one layer of URL-encoding), and returning an\nobject of their values. Note that repeated values in the serialized string will clobber each other.\n\n\n### u.setCookie(k, v, [expires, [path, [domain, [doc]]]]) -> Object\n\nSets a cookie, returning an updated map from cookie key to value.\n\nBy default, the cookie will be set for all paths on the current domain using the current document,\nexpiring on a distant date:\n\n- expires: `'Sun, 24-Mar-2024 11:11:11 GMT'`\n- path: `'/'`\n- domain: `doc.domain`\n- doc: `window.document`\n\n\n\n## Feedback\n\nOpen a ticket at [github](http://github.com/dsc/u.js), or send me [email](mailto:dsc@less.ly?subject=u.js).\n\n\n<a name=\"fn1\" href=\"#fn1_link\">[1]</a>: `u.js` does not provide any DOM manipulation; check out [Zepto.js](http://zeptojs.com) if you\nneed to fiddle with DOM elements.\n\n","maintainers":[{"name":"dsc","email":"dsc@less.ly"}],"time":{"modified":"2022-06-28T02:25:28.042Z","created":"2011-12-11T04:16:50.870Z","0.1.0":"2011-12-11T04:16:52.091Z"},"author":{"name":"David Schoonover","email":"dsc@less.ly","url":"http://less.ly"},"repository":{"type":"git","url":"git://github.com/dsc/u.js.git"},"users":{"dsc":true}}