(length)
| 225 | } |
| 226 | |
| 227 | export function guid(length) { |
| 228 | function s4() { |
| 229 | return Math.floor((1 + Math.random()) * 0x10000) |
| 230 | .toString(16) |
| 231 | .substring(1); |
| 232 | } |
| 233 | |
| 234 | var guid = s4() + s4() + '-' + s4() + '-' + s4() + '-' + |
| 235 | s4() + '-' + s4() + s4() + s4(); |
| 236 | |
| 237 | |
| 238 | if (length && length > 0) { |
| 239 | if (guid.length < length) { |
| 240 | while (guid.length < length) { |
| 241 | guid += guid; |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | if (guid.length > length) { |
| 246 | guid = guid.substring(0, length); |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | return guid; |
| 251 | } |
| 252 | |
| 253 | export function logError(error) { |
| 254 | (console.error || console.log).call(console, error.stack || error); |
no test coverage detected