
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Fast Query is a lightweight and super fast query string parser for node javascript.
With fastquery you don't have to parse the querystring from the url first, we do that for you using the most optimized method just send us the req.url for example.
/test/home/?custom1=zing&custom2=zoom&custom3=blah
custom1=zing&custom2=zoom&custom3=blah
?custom1=zing&custom2=zoom&custom3=blah
npm i fastquery --save
parse(querystring, options, sep, eq) → {parsedQuery}| Name | Type | Default | Description |
|---|---|---|---|
| querystring | string | !required | The query string you wish to parse |
| options | object | 100 | Currently only features options.maxFields |
| sep | string | & | multiple query parameters are separated by the ampersand "&" |
| eq | string | = | Each separation contains a pair field=value |
Assuming you have already installed fastquery
const fq = require('fastquery');
We can set our own options to parse our query string such as maxFields..
let options = {
maxFields: 200
}
let sep = '&';
let eq = '=';
let querystring = '/test/home/?custom1=zing&custom2=zoom&custom3=blah';
let parsed = fq.parse(querystring, options, sep, eq);
console.log(parsed);
This is just a basic example of parsing a query and getting the value from one of the custom fields.
const fq = require('fastquery');
// If were using http webserver we could pass the req.url like so
let req = '/test/home/?custom1=zing&custom2=zoom&custom3=blah'
let query = fq.parse(req);
// Output the parsed query string.
console.log(query);
// Get the value of a specific field
console.log(query.custom1);
These benchmarks also reflect the jsperf results found here slice vs substring vs indexof vs regex
First I did a few simple tests and find the best method for splitting a string.
| Method | Time Taken | Output |
|---|---|---|
| split | 1614.155ms | imsplitthere |
| indexOf | 2308.475ms | imsplitthere |
| slice | 2200.492ms | imsplitthere |
From this result, we can clearly see that split, is clearly faster. So we built our querystring parser based on this regex is slower sorry not included. Maybe later..
Then we tested different methods that I gathered up to see which would be the fastest to parse the whole querystring. I developed the fastest regex, and used the current querystring module to compare against while also using some of that code in our own so its backwards compatible and its nicely written.
| Method | Time Taken | Output |
|---|---|---|
| fastRegex | 8868.756ms | {custom1:'zing',custom2:'zoom',custom3:'blah'} |
| querystring | 31618.960ms | {custom1:'zing',custom2:'zoom',custom3:'blah'} |
| fastquery | 5160.376ms | {custom1:'zing',custom2:'zoom',custom3:'blah'} |
fastquery is the fastest and will parse multiple types of strings. I did benchtest other methods of parsing a string but these 3 stood out... You can replace the decode function on querystring, because its using indexOf it is still slightly slower than fastquery.
fastRegex isn't that far behind.. Its also a very useful regex.
Please checkout the bench.js for source code for the other query string parsers and the full bench test.
Feedback and improvments are always appreciated and help us to improve so please leave some!
Licensed under MIT.
FAQs
Fast Query is a lightweight and super fast query string parser for node javascript.
We found that fastquery demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.