Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove nanoid as dependency #5024

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/utils.js
Expand Up @@ -8,8 +8,6 @@
/**
* Module dependencies.
*/

const {nanoid} = require('nanoid/non-secure');
var path = require('path');
var util = require('util');
var he = require('he');
Expand Down Expand Up @@ -615,11 +613,20 @@ exports.constants = exports.defineConstants({
MOCHA_ID_PROP_NAME
});

const uniqueIDBase =
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_';

/**
* Creates a new unique identifier
* @returns {string} Unique identifier
*/
exports.uniqueID = () => nanoid();
exports.uniqueID = () => {
let id = '';
for (let i = 0; i < 21; i++) {
id += uniqueIDBase[(Math.random() * 64) | 0];
}
return id;
};
Uzlopak marked this conversation as resolved.
Show resolved Hide resolved

exports.assignNewMochaID = obj => {
const id = exports.uniqueID();
Expand Down
17 changes: 0 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Expand Up @@ -63,7 +63,6 @@
"log-symbols": "4.1.0",
"minimatch": "5.0.1",
"ms": "2.1.3",
"nanoid": "3.3.3",
"serialize-javascript": "6.0.0",
"strip-json-comments": "3.1.1",
"supports-color": "8.1.1",
Expand Down
3 changes: 3 additions & 0 deletions test/unit/utils.spec.js
Expand Up @@ -760,5 +760,8 @@ describe('lib/utils', function () {
it('should return a non-empty string', function () {
expect(utils.uniqueID(), 'to be a string').and('not to be empty');
});
it('should have length of 21', function () {
expect(utils.uniqueID().length, 'to equal', 21);
});
});
});