CoolFace
Apppublic

opusdev/vector-similarity-api

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes
README.md134 linesDownload Raw Back to parseurl
1# parseurl2 3[![NPM Version][npm-version-image]][npm-url]4[![NPM Downloads][npm-downloads-image]][npm-url]5[![Node.js Version][node-image]][node-url]6[![Build Status][travis-image]][travis-url]7[![Test Coverage][coveralls-image]][coveralls-url]8 9Parse a URL with memoization.10 11## Install12 13This is a [Node.js](https://nodejs.org/en/) module available through the14[npm registry](https://www.npmjs.com/). Installation is done using the15[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):16 17```sh18$ npm install parseurl19```20 21## API22 23```js24var parseurl = require('parseurl')25```26 27### parseurl(req)28 29Parse the URL of the given request object (looks at the `req.url` property)30and return the result. The result is the same as `url.parse` in Node.js core.31Calling this function multiple times on the same `req` where `req.url` does32not change will return a cached parsed object, rather than parsing again.33 34### parseurl.original(req)35 36Parse the original URL of the given request object and return the result.37This works by trying to parse `req.originalUrl` if it is a string, otherwise38parses `req.url`. The result is the same as `url.parse` in Node.js core.39Calling this function multiple times on the same `req` where `req.originalUrl`40does not change will return a cached parsed object, rather than parsing again.41 42## Benchmark43 44```bash45$ npm run-script bench46 47> parseurl@1.3.3 bench nodejs-parseurl48> node benchmark/index.js49 50  http_parser@2.8.051  node@10.6.052  v8@6.7.288.46-node.1353  uv@1.21.054  zlib@1.2.1155  ares@1.14.056  modules@6457  nghttp2@1.32.058  napi@359  openssl@1.1.0h60  icu@61.161  unicode@10.062  cldr@33.063  tz@2018c64 65> node benchmark/fullurl.js66 67  Parsing URL "http://localhost:8888/foo/bar?user=tj&pet=fluffy"68 69  4 tests completed.70 71  fasturl            x 2,207,842 ops/sec ±3.76% (184 runs sampled)72  nativeurl - legacy x   507,180 ops/sec ±0.82% (191 runs sampled)73  nativeurl - whatwg x   290,044 ops/sec ±1.96% (189 runs sampled)74  parseurl           x   488,907 ops/sec ±2.13% (192 runs sampled)75 76> node benchmark/pathquery.js77 78  Parsing URL "/foo/bar?user=tj&pet=fluffy"79 80  4 tests completed.81 82  fasturl            x 3,812,564 ops/sec ±3.15% (188 runs sampled)83  nativeurl - legacy x 2,651,631 ops/sec ±1.68% (189 runs sampled)84  nativeurl - whatwg x   161,837 ops/sec ±2.26% (189 runs sampled)85  parseurl           x 4,166,338 ops/sec ±2.23% (184 runs sampled)86 87> node benchmark/samerequest.js88 89  Parsing URL "/foo/bar?user=tj&pet=fluffy" on same request object90 91  4 tests completed.92 93  fasturl            x  3,821,651 ops/sec ±2.42% (185 runs sampled)94  nativeurl - legacy x  2,651,162 ops/sec ±1.90% (187 runs sampled)95  nativeurl - whatwg x    175,166 ops/sec ±1.44% (188 runs sampled)96  parseurl           x 14,912,606 ops/sec ±3.59% (183 runs sampled)97 98> node benchmark/simplepath.js99 100  Parsing URL "/foo/bar"101 102  4 tests completed.103 104  fasturl            x 12,421,765 ops/sec ±2.04% (191 runs sampled)105  nativeurl - legacy x  7,546,036 ops/sec ±1.41% (188 runs sampled)106  nativeurl - whatwg x    198,843 ops/sec ±1.83% (189 runs sampled)107  parseurl           x 24,244,006 ops/sec ±0.51% (194 runs sampled)108 109> node benchmark/slash.js110 111  Parsing URL "/"112 113  4 tests completed.114 115  fasturl            x 17,159,456 ops/sec ±3.25% (188 runs sampled)116  nativeurl - legacy x 11,635,097 ops/sec ±3.79% (184 runs sampled)117  nativeurl - whatwg x    240,693 ops/sec ±0.83% (189 runs sampled)118  parseurl           x 42,279,067 ops/sec ±0.55% (190 runs sampled)119```120 121## License122 123  [MIT](LICENSE)124 125[coveralls-image]: https://badgen.net/coveralls/c/github/pillarjs/parseurl/master126[coveralls-url]: https://coveralls.io/r/pillarjs/parseurl?branch=master127[node-image]: https://badgen.net/npm/node/parseurl128[node-url]: https://nodejs.org/en/download129[npm-downloads-image]: https://badgen.net/npm/dm/parseurl130[npm-url]: https://npmjs.org/package/parseurl131[npm-version-image]: https://badgen.net/npm/v/parseurl132[travis-image]: https://badgen.net/travis/pillarjs/parseurl/master133[travis-url]: https://travis-ci.org/pillarjs/parseurl134