-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge upstream branch 'master' into patch-1
- Loading branch information
Showing
45 changed files
with
5,565 additions
and
349 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 |
---|---|---|
|
@@ -14,7 +14,7 @@ vendor | |
build | ||
dest | ||
dist | ||
src | ||
lib | ||
lib-cov | ||
coverage | ||
nbproject | ||
|
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,2 +1,7 @@ | ||
test | ||
.travis.yml | ||
benchmark | ||
CONTRIBUTING.md | ||
src | ||
.gitignore | ||
babel.config.json |
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,4 +1,3 @@ | ||
language: node_js | ||
node_js: | ||
- "0.11" | ||
- "0.10" | ||
- "node" |
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,30 @@ | ||
# Contributing to dateformat | ||
|
||
Thanks for taking the time to contribute to dateformat!!! | ||
Feel free to raise a PR or Issue for any suggested improvements to the package. | ||
|
||
## Running dateformat | ||
|
||
To run dateformat, first clone the repository to your local machine. | ||
Then run `npm i` to install all the required dependencies. | ||
Then build dateformat by running `npm run build`. | ||
Then you can import dateformat from the `lib` directory and call it as needed. | ||
|
||
## Benchmarking | ||
|
||
If you want to try and improve the performance of dateformat, you can use the benchmarking script. | ||
To use the script: | ||
|
||
- Copy the contents of the `lib/dateformat.js` file into the `benchmark/previousDateFormat.js` file. | ||
- Make your code changes to `lib/dateformat.js` as you normaly would | ||
- run `npm run benchmark` in root directory to see the comparison of performance before and after your change | ||
|
||
A positive number for improvement indicates that your changes have improved the speed of dateformat. | ||
Any different between -5% and 5% can be disregarded as minor variance. | ||
It is recommended that you run this benchmark after any changes to the business logic of dateformat. | ||
This is to ensure that there is no detrimental impact on performance from your change. | ||
A screenshot it the PR would be much appreciated also. | ||
|
||
## Running Tests | ||
|
||
To test dateformat, just run `npm run test` and see the results. |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@babel/env", | ||
{ | ||
"targets": "> 0.01%, not dead" | ||
} | ||
] | ||
] | ||
} |
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,38 @@ | ||
var previousDateFormat = require("./previousDateFormat"); | ||
var newDateFormat = require("../lib/dateformat"); | ||
|
||
const masks = [ | ||
"d", | ||
"W", | ||
"o", | ||
"N", | ||
"shortDate", | ||
"fullDate", | ||
"longTime", | ||
"default", | ||
]; | ||
let results = []; | ||
|
||
masks.forEach((mask) => { | ||
const previousSpeed = getSpeed(false, mask); | ||
const newSpeed = getSpeed(true, mask); | ||
results.push({ | ||
mask: mask, | ||
previous: previousSpeed + "ms", | ||
new: newSpeed + "ms", | ||
improvement: Math.round((previousSpeed / newSpeed - 1) * 100, 2) + "%", | ||
}); | ||
}); | ||
|
||
function getSpeed(newVersion, mask) { | ||
const startTime = new Date(); | ||
const date = new Date(); | ||
for (var i = 0; i < 100_000; i++) { | ||
if (newVersion) newDateFormat(date, mask); | ||
else previousDateFormat(date, mask); | ||
} | ||
const endTime = new Date(); | ||
return endTime - startTime; | ||
} | ||
|
||
console.table(results); |
Oops, something went wrong.