-
Notifications
You must be signed in to change notification settings - Fork 0
/
_merge-with.scss
37 lines (33 loc) · 1.24 KB
/
_merge-with.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
@import 'merge-with-key';
// as gross as this is there is no way that I know of to get around it. :(
$_sass-fire-merge-with-key-fn: '';
/// Creates a new object with the own properties of the two provided objects. If
/// a key exists in both objects, the provided function is applied to the values
/// associated with the key in each object, with the result being used as the
/// value associated with the key in the returned object.
///
/// @group object
/// @param {Function} fn function to call when two keys match
/// @param {Object} l left object
/// @param {Object} r right object
/// @return {Object} merged object
///
/// @see merge-deep-with-key
/// @see merge
/// @see merge-with-key
///
/// @example scss - merge-with
///
/// $merge-objs: merge-with(concat,
/// ( a: true, values: [10, 20] )
/// ( b: true, values: [15, 35] )
/// );
/// @debug $merge-objs; //=> ( a: true, b: true, values: [10, 20, 15, 35] )
@function merge-with($fn, $l, $r) {
$_sass-fire-merge-with-key-fn: $fn !global;
@return merge-with-key(_sass-fire-merge-with-caller, $l, $r);
}
// calls the passed in merge-with function without key
@function _sass-fire-merge-with-caller($k, $l, $r) {
@return call(get-function($_sass-fire-merge-with-key-fn), $l, $r);
}