Skip to content

Commit

Permalink
break: use named uid export
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Oct 29, 2020
1 parent 1d6923e commit 6c52bbd
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default function (len?: number): string;
export function uid(len?: number): string;
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var IDX=256, HEX=[], SIZE=256, BUFFER;
while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);

export default function (len) {
export function uid(len) {
var i=0, tmp=(len || 11);
if (!BUFFER || ((IDX + tmp) > SIZE)) {
for (BUFFER='',IDX=0; i < SIZE; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/secure.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default function (len?: number): string;
export function uid(len?: number): string;
2 changes: 1 addition & 1 deletion src/secure.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { random } from '@lukeed/csprng';
var IDX=256, HEX=[], SIZE=256*16, BUFFER;
while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);

export default function (len) {
export function uid(len) {
var str='', tmp=(len || 11), num=(1+tmp) / 2 | 0;
if (!BUFFER || ((IDX + num) > SIZE)) {
BUFFER = random(SIZE);
Expand Down
2 changes: 1 addition & 1 deletion src/single.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default function (len?: number): string;
export function uid(len?: number): string;
2 changes: 1 addition & 1 deletion src/single.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var IDX=36, HEX='';
while (IDX--) HEX += IDX.toString(36);

export default function (len) {
export function uid(len) {
var str='', num = len || 11;
while (num--) str += HEX[Math.random() * 36 | 0];
return str;
Expand Down
2 changes: 1 addition & 1 deletion test/collisions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const uid = require('../dist');
const { uid } = require('../dist');

// $ node test/collisions 16 1e7
const [len=8, cycles] = process.argv.slice(2);
Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test } from 'uvu';
import * as assert from 'uvu/assert';
import uid from '../src';
import { uid } from '../src';

test('exports', () => {
assert.type(uid, 'function', 'exports function');
Expand Down
2 changes: 1 addition & 1 deletion test/secure.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test } from 'uvu';
import * as assert from 'uvu/assert';
import uid from '../src/secure';
import { uid } from '../src/secure';

test('exports', () => {
assert.type(uid, 'function', 'exports function');
Expand Down
2 changes: 1 addition & 1 deletion test/single.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test } from 'uvu';
import * as assert from 'uvu/assert';
import uid from '../src/single';
import { uid } from '../src/single';

test('exports', () => {
assert.type(uid, 'function', 'exports function');
Expand Down

2 comments on commit 6c52bbd

@gustawdaniel
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should be highlighted in docs

@lukeed
Copy link
Owner Author

@lukeed lukeed commented on 6c52bbd Nov 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.