mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-24 12:07:10 -04:00
Publish tests.
This commit is contained in:
parent
5a8ecd593d
commit
c396800dfa
40 changed files with 21478 additions and 1 deletions
32
test/util/uniq.js
Normal file
32
test/util/uniq.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var PREFIX = 'UQ';
|
||||
var SUFFIX = 'ID';
|
||||
var LENGTH = 4;
|
||||
var RE = new RegExp('^' + PREFIX + '\\d{' + LENGTH + '}' + SUFFIX + '$');
|
||||
|
||||
var counter = 0;
|
||||
|
||||
function uniqId() {
|
||||
|
||||
counter += 1;
|
||||
return PREFIX + ('00000000' + counter).substr(-LENGTH) + SUFFIX;
|
||||
}
|
||||
|
||||
function uniqObj() {
|
||||
|
||||
return {uniqId: uniqId()};
|
||||
}
|
||||
|
||||
function isUniqId(uid) {
|
||||
|
||||
return RE.test(uid);
|
||||
}
|
||||
|
||||
window.util = window.util || {};
|
||||
window.util.uniqId = uniqId;
|
||||
window.util.uniqObj = uniqObj;
|
||||
window.util.isUniqId = isUniqId;
|
||||
|
||||
}());
|
Loading…
Add table
Add a link
Reference in a new issue