Skip to content

Commit 80bf314

Browse files
committed
refactor(rich-text-types): you don't need lodash uniqBy []
1 parent 0670f95 commit 80bf314

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

packages/rich-text-types/src/validator/assert.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import isPlainObject from 'is-plain-obj';
2+
3+
import { ValidationError } from '.';
24
import {
35
maxSizeError,
46
typeMismatchError,
@@ -8,8 +10,6 @@ import {
810
minSizeError,
911
} from './errors';
1012
import type { Path } from './path';
11-
import { uniqWith } from 'lodash';
12-
import { ValidationError } from '.';
1313

1414
export class ObjectAssertion {
1515
private _errors: ValidationError[] = [];
@@ -30,9 +30,10 @@ export class ObjectAssertion {
3030
path: error.path,
3131
});
3232

33-
return uniqWith(this._errors, (a, b) => {
34-
return serializeError(a) === serializeError(b);
35-
});
33+
return this._errors.filter(
34+
(error, index) =>
35+
this._errors.findIndex((step) => serializeError(error) === serializeError(step)) === index,
36+
);
3637
}
3738

3839
/**

packages/rich-text-types/src/validator/node.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type { Path } from './path';
2-
import { ObjectAssertion } from './assert';
31
import { ValidationError } from '.';
42
import {
53
AssetHyperlink,
@@ -11,6 +9,8 @@ import {
119
ResourceLinkInline,
1210
} from '../nodeTypes';
1311
import { Block, Document, Inline } from '../types';
12+
import { ObjectAssertion } from './assert';
13+
import type { Path } from './path';
1414

1515
export type Node = Document | Block | Inline;
1616

packages/rich-text-types/src/validator/text.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { Path } from './path';
2-
import { ObjectAssertion } from './assert';
31
import { ValidationError } from '.';
42
import { Text } from '../types';
3+
import { ObjectAssertion } from './assert';
4+
import type { Path } from './path';
55

66
export function assertText(text: Text, path: Path): ValidationError[] {
77
const $ = new ObjectAssertion(text, path);

0 commit comments

Comments
 (0)