-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from cdeutsch/sync-query-string-v6.13.0
Sync query string v6.13.0
- Loading branch information
Showing
11 changed files
with
222 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
language: node_js | ||
node_js: | ||
- '14' | ||
- '12' | ||
- '10' | ||
- '8' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
'use strict'; | ||
const Benchmark = require('benchmark'); | ||
const queryString = require('.'); | ||
|
||
const {stringify, stringifyUrl} = queryString; | ||
const suite = new Benchmark.Suite(); | ||
|
||
// Fixtures | ||
const TEST_OBJECT = { | ||
genre: 'Epic fantasy', | ||
author: '', | ||
page: 2, | ||
published: true, | ||
symbols: 'πµ', | ||
chapters: [1, 2, 3], | ||
none: null | ||
}; | ||
const TEST_HOST = 'https://foo.bar/'; | ||
const TEST_STRING = stringify(TEST_OBJECT); | ||
const TEST_BRACKETS_STRING = stringify(TEST_OBJECT, {arrayFormat: 'bracket'}); | ||
const TEST_INDEX_STRING = stringify(TEST_OBJECT, {arrayFormat: 'index'}); | ||
const TEST_COMMA_STRING = stringify(TEST_OBJECT, {arrayFormat: 'comma'}); | ||
const TEST_URL = stringifyUrl({url: TEST_HOST, query: TEST_OBJECT}); | ||
|
||
// Creates a test case and adds it to the suite | ||
const defineTestCase = (methodName, input, options) => { | ||
const fn = queryString[methodName]; | ||
const label = options ? ` (${stringify(options)})` : ''; | ||
|
||
suite.add(methodName + label, () => fn(input, options || {})); | ||
}; | ||
|
||
// Define all test cases | ||
|
||
// Parse | ||
defineTestCase('parse', TEST_STRING); | ||
defineTestCase('parse', TEST_STRING, {parseNumbers: true}); | ||
defineTestCase('parse', TEST_STRING, {parseBooleans: true}); | ||
defineTestCase('parse', TEST_STRING, {sort: false}); | ||
defineTestCase('parse', TEST_STRING, {decode: false}); | ||
defineTestCase('parse', TEST_BRACKETS_STRING, {arrayFormat: 'bracket'}); | ||
defineTestCase('parse', TEST_INDEX_STRING, {arrayFormat: 'index'}); | ||
defineTestCase('parse', TEST_COMMA_STRING, {arrayFormat: 'comma'}); | ||
|
||
// Stringify | ||
defineTestCase('stringify', TEST_OBJECT); | ||
defineTestCase('stringify', TEST_OBJECT, {strict: false}); | ||
defineTestCase('stringify', TEST_OBJECT, {encode: false}); | ||
defineTestCase('stringify', TEST_OBJECT, {skipNull: true}); | ||
defineTestCase('stringify', TEST_OBJECT, {skipEmptyString: true}); | ||
defineTestCase('stringify', TEST_OBJECT, {arrayFormat: 'bracket'}); | ||
defineTestCase('stringify', TEST_OBJECT, {arrayFormat: 'index'}); | ||
defineTestCase('stringify', TEST_OBJECT, {arrayFormat: 'comma'}); | ||
|
||
// Extract | ||
defineTestCase('extract', TEST_URL); | ||
|
||
// ParseUrl | ||
defineTestCase('parseUrl', TEST_URL); | ||
|
||
// StringifyUrl | ||
defineTestCase('stringifyUrl', {url: TEST_HOST, query: TEST_OBJECT}); | ||
|
||
// Log/display the results | ||
suite.on('cycle', event => { | ||
const {name, hz} = event.target; | ||
const opsPerSec = Math.round(hz).toLocaleString(); | ||
|
||
console.log(name.padEnd(36, '_') + opsPerSec.padStart(12, '_') + ' ops/s'); | ||
}); | ||
|
||
suite.run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
MIT License | ||
|
||
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com) | ||
Copyright (c) Sindre Sorhus <[email protected]> (http://sindresorhus.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
{ | ||
"name": "query-string-for-all", | ||
"version": "6.12.1", | ||
"version": "6.13.0", | ||
"description": "Parse and stringify URL query strings", | ||
"license": "MIT", | ||
"repository": "cdeutsch/query-string-for-all", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "[email protected]", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"benchmark": "node benchmark.js", | ||
"build": "webpack --mode production", | ||
"test": "npm run build && xo && ava && tsd" | ||
}, | ||
|
@@ -45,6 +46,7 @@ | |
"ava": "^1.4.1", | ||
"babel-loader": "^8.0.6", | ||
"decode-uri-component": "^0.2.0", | ||
"benchmark": "^2.1.4", | ||
"deep-equal": "^1.0.1", | ||
"fast-check": "^1.5.0", | ||
"split-on-first": "^1.0.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.