Skip to content

Commit

Permalink
Creating 'this.uuid()' from lexical scope function, updating tests to…
Browse files Browse the repository at this point in the history
… remove outdated 'logging' option
  • Loading branch information
avoidwork committed Jun 16, 2024
1 parent 7366b1f commit dc81050
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 33 deletions.
10 changes: 7 additions & 3 deletions dist/haro.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @copyright 2024 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 15.1.1
* @version 15.2.0
*/
'use strict';

Expand Down Expand Up @@ -49,7 +49,7 @@ function randomUUID () {
const uuid = typeof crypto === STRING_OBJECT ? crypto.randomUUID.bind(crypto) : randomUUID;

class Haro {
constructor ({delimiter = STRING_PIPE, id = uuid(), index = [], key = STRING_EMPTY, versioning = false} = {}) {
constructor ({delimiter = STRING_PIPE, id = this.uuid(), index = [], key = STRING_EMPTY, versioning = false} = {}) {
this.data = new Map();
this.delimiter = delimiter;
this.id = id;
Expand Down Expand Up @@ -377,7 +377,7 @@ class Haro {

set (key = null, data = {}, batch = false, override = false) {
if (key === null) {
key = data[this.key] ?? uuid();
key = data[this.key] ?? this.uuid();
}

let x = {...data, [this.key]: key};
Expand Down Expand Up @@ -468,6 +468,10 @@ class Haro {
return result;
}

uuid () {
return uuid();
}

values () {
return this.data.values();
}
Expand Down
10 changes: 7 additions & 3 deletions dist/haro.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @copyright 2024 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 15.1.1
* @version 15.2.0
*/
const STRING_COMMA = ",";
const STRING_EMPTY = "";
Expand Down Expand Up @@ -43,7 +43,7 @@ function randomUUID () {
}

const uuid = typeof crypto === STRING_OBJECT ? crypto.randomUUID.bind(crypto) : randomUUID;class Haro {
constructor ({delimiter = STRING_PIPE, id = uuid(), index = [], key = STRING_EMPTY, versioning = false} = {}) {
constructor ({delimiter = STRING_PIPE, id = this.uuid(), index = [], key = STRING_EMPTY, versioning = false} = {}) {
this.data = new Map();
this.delimiter = delimiter;
this.id = id;
Expand Down Expand Up @@ -371,7 +371,7 @@ const uuid = typeof crypto === STRING_OBJECT ? crypto.randomUUID.bind(crypto) :

set (key = null, data = {}, batch = false, override = false) {
if (key === null) {
key = data[this.key] ?? uuid();
key = data[this.key] ?? this.uuid();
}

let x = {...data, [this.key]: key};
Expand Down Expand Up @@ -462,6 +462,10 @@ const uuid = typeof crypto === STRING_OBJECT ? crypto.randomUUID.bind(crypto) :
return result;
}

uuid () {
return uuid();
}

values () {
return this.data.values();
}
Expand Down
4 changes: 2 additions & 2 deletions dist/haro.min.js

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

2 changes: 1 addition & 1 deletion dist/haro.min.js.map

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions dist/haro.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @copyright 2024 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 15.1.1
* @version 15.2.0
*/
(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports):typeof define==='function'&&define.amd?define(['exports'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.lru={}));})(this,(function(exports){'use strict';const STRING_COMMA = ",";
const STRING_EMPTY = "";
Expand Down Expand Up @@ -43,7 +43,7 @@ function randomUUID () {
}

const uuid = typeof crypto === STRING_OBJECT ? crypto.randomUUID.bind(crypto) : randomUUID;class Haro {
constructor ({delimiter = STRING_PIPE, id = uuid(), index = [], key = STRING_EMPTY, versioning = false} = {}) {
constructor ({delimiter = STRING_PIPE, id = this.uuid(), index = [], key = STRING_EMPTY, versioning = false} = {}) {
this.data = new Map();
this.delimiter = delimiter;
this.id = id;
Expand Down Expand Up @@ -371,7 +371,7 @@ const uuid = typeof crypto === STRING_OBJECT ? crypto.randomUUID.bind(crypto) :

set (key = null, data = {}, batch = false, override = false) {
if (key === null) {
key = data[this.key] ?? uuid();
key = data[this.key] ?? this.uuid();
}

let x = {...data, [this.key]: key};
Expand Down Expand Up @@ -462,6 +462,10 @@ const uuid = typeof crypto === STRING_OBJECT ? crypto.randomUUID.bind(crypto) :
return result;
}

uuid () {
return uuid();
}

values () {
return this.data.values();
}
Expand Down
Loading

0 comments on commit dc81050

Please sign in to comment.