Skip to content

Commit

Permalink
Updating some function signatures and types def
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Jul 21, 2024
1 parent ef62513 commit b579b21
Show file tree
Hide file tree
Showing 17 changed files with 265 additions and 80 deletions.
10 changes: 0 additions & 10 deletions .npmignore

This file was deleted.

2 changes: 1 addition & 1 deletion benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {haro} from "../dist/haro.cjs";
import {precise} from "precise";
import {readFile} from 'node:fs/promises';
import {readFile} from "node:fs/promises";

const fileUrl = new URL("./data.json", import.meta.url);
const data = JSON.parse(await readFile(fileUrl, "utf8"));
Expand Down
27 changes: 17 additions & 10 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.2.4
* @version 15.2.5
*/
'use strict';

Expand Down Expand Up @@ -78,17 +78,19 @@ class Haro {
return this.onbatch(this.beforeBatch(args, type).map(fn), type);
}

beforeBatch (arg) {
beforeBatch (arg, type = STRING_EMPTY) { // eslint-disable-line no-unused-vars
return arg;
}

beforeClear () {
}

beforeDelete () {
beforeDelete (key = STRING_EMPTY, batch = false) {
return [key, batch];
}

beforeSet () {
beforeSet (key = STRING_EMPTY, batch = false) {
return [key, batch];
}

clear () {
Expand Down Expand Up @@ -265,28 +267,33 @@ class Haro {
if (Array.isArray(a) && Array.isArray(b)) {
a = override ? b : a.concat(b);
} else if (a instanceof Object && b instanceof Object) {
this.each(Object.keys(b), i => (a[i] = this.merge(a[i], b[i], override)));
this.each(Object.keys(b), i => {
a[i] = this.merge(a[i], b[i], override);
});
} else {
a = b;
}

return a;
}

onbatch (arg) {
onbatch (arg, type = STRING_EMPTY) { // eslint-disable-line no-unused-vars
return arg;
}

onclear () {
}

ondelete () {
ondelete (key = STRING_EMPTY, batch = false) {
return [key, batch];
}

onoverride () {
onoverride (type = STRING_EMPTY) {
return type;
}

onset () {
onset (arg = {}, batch = false) {
return [arg, batch];
}

override (data, type = STRING_RECORDS) {
Expand Down Expand Up @@ -423,7 +430,7 @@ class Haro {

sortBy (index = STRING_EMPTY, raw = false) {
if (index === STRING_EMPTY) {
throw new Error(STRING_INVALID_FIELD)
throw new Error(STRING_INVALID_FIELD);
}

const result = [],
Expand Down
27 changes: 17 additions & 10 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.2.4
* @version 15.2.5
*/
const STRING_COMMA = ",";
const STRING_EMPTY = "";
Expand Down Expand Up @@ -72,17 +72,19 @@ const uuid = typeof crypto === STRING_OBJECT ? crypto.randomUUID.bind(crypto) :
return this.onbatch(this.beforeBatch(args, type).map(fn), type);
}

beforeBatch (arg) {
beforeBatch (arg, type = STRING_EMPTY) { // eslint-disable-line no-unused-vars
return arg;
}

beforeClear () {
}

beforeDelete () {
beforeDelete (key = STRING_EMPTY, batch = false) {
return [key, batch];
}

beforeSet () {
beforeSet (key = STRING_EMPTY, batch = false) {
return [key, batch];
}

clear () {
Expand Down Expand Up @@ -259,28 +261,33 @@ const uuid = typeof crypto === STRING_OBJECT ? crypto.randomUUID.bind(crypto) :
if (Array.isArray(a) && Array.isArray(b)) {
a = override ? b : a.concat(b);
} else if (a instanceof Object && b instanceof Object) {
this.each(Object.keys(b), i => (a[i] = this.merge(a[i], b[i], override)));
this.each(Object.keys(b), i => {
a[i] = this.merge(a[i], b[i], override);
});
} else {
a = b;
}

return a;
}

onbatch (arg) {
onbatch (arg, type = STRING_EMPTY) { // eslint-disable-line no-unused-vars
return arg;
}

onclear () {
}

ondelete () {
ondelete (key = STRING_EMPTY, batch = false) {
return [key, batch];
}

onoverride () {
onoverride (type = STRING_EMPTY) {
return type;
}

onset () {
onset (arg = {}, batch = false) {
return [arg, batch];
}

override (data, type = STRING_RECORDS) {
Expand Down Expand Up @@ -417,7 +424,7 @@ const uuid = typeof crypto === STRING_OBJECT ? crypto.randomUUID.bind(crypto) :

sortBy (index = STRING_EMPTY, raw = false) {
if (index === STRING_EMPTY) {
throw new Error(STRING_INVALID_FIELD)
throw new Error(STRING_INVALID_FIELD);
}

const result = [],
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.

27 changes: 17 additions & 10 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.2.4
* @version 15.2.5
*/
(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 @@ -72,17 +72,19 @@ const uuid = typeof crypto === STRING_OBJECT ? crypto.randomUUID.bind(crypto) :
return this.onbatch(this.beforeBatch(args, type).map(fn), type);
}

beforeBatch (arg) {
beforeBatch (arg, type = STRING_EMPTY) { // eslint-disable-line no-unused-vars
return arg;
}

beforeClear () {
}

beforeDelete () {
beforeDelete (key = STRING_EMPTY, batch = false) {
return [key, batch];
}

beforeSet () {
beforeSet (key = STRING_EMPTY, batch = false) {
return [key, batch];
}

clear () {
Expand Down Expand Up @@ -259,28 +261,33 @@ const uuid = typeof crypto === STRING_OBJECT ? crypto.randomUUID.bind(crypto) :
if (Array.isArray(a) && Array.isArray(b)) {
a = override ? b : a.concat(b);
} else if (a instanceof Object && b instanceof Object) {
this.each(Object.keys(b), i => (a[i] = this.merge(a[i], b[i], override)));
this.each(Object.keys(b), i => {
a[i] = this.merge(a[i], b[i], override);
});
} else {
a = b;
}

return a;
}

onbatch (arg) {
onbatch (arg, type = STRING_EMPTY) { // eslint-disable-line no-unused-vars
return arg;
}

onclear () {
}

ondelete () {
ondelete (key = STRING_EMPTY, batch = false) {
return [key, batch];
}

onoverride () {
onoverride (type = STRING_EMPTY) {
return type;
}

onset () {
onset (arg = {}, batch = false) {
return [arg, batch];
}

override (data, type = STRING_RECORDS) {
Expand Down Expand Up @@ -417,7 +424,7 @@ const uuid = typeof crypto === STRING_OBJECT ? crypto.randomUUID.bind(crypto) :

sortBy (index = STRING_EMPTY, raw = false) {
if (index === STRING_EMPTY) {
throw new Error(STRING_INVALID_FIELD)
throw new Error(STRING_INVALID_FIELD);
}

const result = [],
Expand Down
Loading

0 comments on commit b579b21

Please sign in to comment.