playbook_ui 14.15.0.pre.alpha.play1917lodashremoval2of36613 → 14.15.0.pre.alpha.play1917lodashremoval2of36615
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7250a006190c9fd3ad50753379407ed9d56eaf7bbbe45bf675aa1cd3386adb19
|
4
|
+
data.tar.gz: f69959838cbc85aad8736d740beaed172aa92a0353751082eaf803c75b224940
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8de325ab14219ca126a14a1301d004bcdf80d7d1a6e92f608d540bd2bd4c85b46e0aee60db4f3ea8da19d6d55e123c0bbf870b6ef97426cafec47c6bb8a7e93d
|
7
|
+
data.tar.gz: a34995b8ba52bfd48be3268128b905d1e880a614994c75f48116eb07a271ce23a5627c340fd8061640def912fe0ab1352539003aef732939c9267674ea5d2b75
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { isEmpty, get, isString, uniqueId, omitBy } from './object';
|
1
|
+
import { isEmpty, get, isString, uniqueId, omitBy, noop, merge, filter, find, partial } from './object';
|
2
2
|
|
3
3
|
describe('Lodash functions', () => {
|
4
4
|
describe('isEmpty', () => {
|
@@ -96,4 +96,142 @@ describe('Lodash functions', () => {
|
|
96
96
|
expect(objWithSmallValues).toEqual(obj);
|
97
97
|
});
|
98
98
|
});
|
99
|
+
|
100
|
+
describe('noop', () => {
|
101
|
+
test('should do nothing and return undefined', () => {
|
102
|
+
expect(noop()).toBeUndefined();
|
103
|
+
});
|
104
|
+
});
|
105
|
+
|
106
|
+
describe('merge', () => {
|
107
|
+
test('merges two objects correctly', () => {
|
108
|
+
const obj1 = { a: 1, b: { x: 10 } };
|
109
|
+
const obj2 = { b: { y: 20 }, c: 3 };
|
110
|
+
expect(merge(obj1, obj2)).toEqual({ a: 1, b: { x: 10, y: 20 }, c: 3 });
|
111
|
+
});
|
112
|
+
|
113
|
+
test('when keys repeat use last occurrence value', () => {
|
114
|
+
const obj1 = { a: 1 };
|
115
|
+
const obj2 = { b: 2 };
|
116
|
+
const obj3 = { a: 3, c: 4 };
|
117
|
+
expect(merge(obj1, obj2, obj3)).toEqual({ a: 3, b: 2, c: 4 });
|
118
|
+
});
|
119
|
+
|
120
|
+
test('ignores non-object arguments', () => {
|
121
|
+
expect(merge(null, { a: 1 })).toEqual({ a: 1 });
|
122
|
+
expect(merge(undefined, { a: 1 })).toEqual({ a: 1 });
|
123
|
+
});
|
124
|
+
});
|
125
|
+
|
126
|
+
describe('filter', () => {
|
127
|
+
test('filters an array using a function predicate', () => {
|
128
|
+
const arr = [1, 2, 3, 4, 5];
|
129
|
+
const isEven = (n) => n % 2 === 0;
|
130
|
+
expect(filter(arr, isEven)).toEqual([2, 4]);
|
131
|
+
});
|
132
|
+
|
133
|
+
test('filters an array using a string predicate', () => {
|
134
|
+
const arr = [
|
135
|
+
{ active: true, name: 'John' },
|
136
|
+
{ active: false, name: 'Jane' },
|
137
|
+
{ active: true, name: 'Doe' }
|
138
|
+
];
|
139
|
+
expect(filter(arr, 'active')).toEqual([
|
140
|
+
{ active: true, name: 'John' },
|
141
|
+
{ active: true, name: 'Doe' }
|
142
|
+
]);
|
143
|
+
});
|
144
|
+
|
145
|
+
test('filters an array using an array predicate', () => {
|
146
|
+
const arr = [
|
147
|
+
{ type: 'fruit', name: 'apple' },
|
148
|
+
{ type: 'vegetable', name: 'carrot' },
|
149
|
+
{ type: 'fruit', name: 'banana' }
|
150
|
+
];
|
151
|
+
expect(filter(arr, ['type', 'fruit'])).toEqual([
|
152
|
+
{ type: 'fruit', name: 'apple' },
|
153
|
+
{ type: 'fruit', name: 'banana' }
|
154
|
+
]);
|
155
|
+
});
|
156
|
+
|
157
|
+
test('filters an array using an object predicate', () => {
|
158
|
+
const arr = [
|
159
|
+
{ type: 'fruit', name: 'apple', color: 'red' },
|
160
|
+
{ type: 'fruit', name: 'banana', color: 'yellow' },
|
161
|
+
{ type: 'vegetable', name: 'carrot', color: 'orange' }
|
162
|
+
];
|
163
|
+
expect(filter(arr, { type: 'fruit', color: 'red' })).toEqual([
|
164
|
+
{ type: 'fruit', name: 'apple', color: 'red' }
|
165
|
+
]);
|
166
|
+
});
|
167
|
+
});
|
168
|
+
|
169
|
+
describe('find', () => {
|
170
|
+
test('finds an element using a function predicate', () => {
|
171
|
+
const arr = [1, 2, 3, 4, 5];
|
172
|
+
const greaterThanThree = (n) => n > 3;
|
173
|
+
expect(find(arr, greaterThanThree)).toBe(4);
|
174
|
+
});
|
175
|
+
|
176
|
+
test('finds an element using a string predicate', () => {
|
177
|
+
const arr = [
|
178
|
+
{ active: false, name: 'John' },
|
179
|
+
{ active: true, name: 'Jane' },
|
180
|
+
{ active: true, name: 'Doe' }
|
181
|
+
];
|
182
|
+
expect(find(arr, 'active')).toEqual({ active: true, name: 'Jane' });
|
183
|
+
});
|
184
|
+
|
185
|
+
test('finds an element using an array predicate', () => {
|
186
|
+
const arr = [
|
187
|
+
{ type: 'fruit', name: 'apple' },
|
188
|
+
{ type: 'vegetable', name: 'carrot' },
|
189
|
+
{ type: 'fruit', name: 'banana' }
|
190
|
+
];
|
191
|
+
expect(find(arr, ['type', 'vegetable'])).toEqual({ type: 'vegetable', name: 'carrot' });
|
192
|
+
});
|
193
|
+
|
194
|
+
test('finds an element using an object predicate', () => {
|
195
|
+
const arr = [
|
196
|
+
{ type: 'fruit', name: 'apple', color: 'red' },
|
197
|
+
{ type: 'fruit', name: 'banana', color: 'yellow' },
|
198
|
+
{ type: 'vegetable', name: 'carrot', color: 'orange' }
|
199
|
+
];
|
200
|
+
expect(find(arr, { name: 'banana', color: 'yellow' })).toEqual({ type: 'fruit', name: 'banana', color: 'yellow' });
|
201
|
+
});
|
202
|
+
|
203
|
+
test('returns undefined if no element matches', () => {
|
204
|
+
const arr = [{ id: 1 }, { id: 2 }];
|
205
|
+
expect(find(arr, { id: 3 })).toBeUndefined();
|
206
|
+
});
|
207
|
+
});
|
208
|
+
|
209
|
+
describe('partial', () => {
|
210
|
+
function add(a, b, c) {
|
211
|
+
return a + b + c;
|
212
|
+
}
|
213
|
+
|
214
|
+
test('partials arguments without placeholders', () => {
|
215
|
+
const add5 = partial(add, 2, 3);
|
216
|
+
expect(add5(4)).toBe(9);
|
217
|
+
});
|
218
|
+
|
219
|
+
test('partials arguments with placeholders', () => {
|
220
|
+
const addWithPlaceholder = partial(add, partial.placeholder, 3, partial.placeholder);
|
221
|
+
expect(addWithPlaceholder(2, 4)).toBe(9);
|
222
|
+
});
|
223
|
+
|
224
|
+
test('returns correct result when all arguments are pre-filled', () => {
|
225
|
+
const addAll = partial(add, 1, 2, 3);
|
226
|
+
expect(addAll()).toBe(6);
|
227
|
+
});
|
228
|
+
|
229
|
+
test('appends extra arguments when provided', () => {
|
230
|
+
function join(...args) {
|
231
|
+
return args.join('_');
|
232
|
+
}
|
233
|
+
const joinPartial = partial(join, 'a');
|
234
|
+
expect(joinPartial('b', 'c')).toBe('a_b_c');
|
235
|
+
});
|
236
|
+
});
|
99
237
|
});
|
@@ -97,7 +97,7 @@ export const partial = <F extends (...args: unknown[]) => unknown>(
|
|
97
97
|
const finalArgs = partials.map(arg =>
|
98
98
|
arg === placeholder ? args[argIndex++] : arg
|
99
99
|
);
|
100
|
-
return fn(...(finalArgs.concat(args.slice(argIndex)) as Parameters<F>))
|
100
|
+
return fn(...(finalArgs.concat(args.slice(argIndex)) as Parameters<F>)) as ReturnType<F>;
|
101
101
|
};
|
102
102
|
};
|
103
103
|
|
data/lib/playbook/version.rb
CHANGED
metadata
CHANGED