File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 114114 } ;
115115 }
116116
117+ function uid ( length = 36 ) {
118+ let pattern = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' ;
119+ if ( length > 36 ) {
120+ length = 36 ; // If requested length is more than 36, set it to 36.
121+ }
122+
123+ let uuid = pattern . replace ( / [ x y ] / g, function ( c ) {
124+ var r = ( Math . random ( ) * 16 ) | 0 ;
125+ var v = c === 'x' ? r : ( r & 0x3 | 0x8 ) ;
126+ return v . toString ( 16 ) ;
127+ } ) . substring ( 0 , length ) ; // Truncate to the requested length.
128+
129+ return uuid ;
130+ }
131+
117132 function checkValue ( value ) {
118133 if ( / { { \s * ( [ \w \W ] + ) \s * } } / g. test ( value ) ) return false ;
119134 else return true ;
12861301 return {
12871302 getRelativePath,
12881303 ObjectId,
1304+ uid,
12891305 checkValue,
12901306 isValidDate,
12911307 dotNotationToObject,
You can’t perform that action at this time.
0 commit comments