Skip to content

Commit

Permalink
feat(object.wrapper): add wrapper functions in combination with `obje…
Browse files Browse the repository at this point in the history
…ct.call()` function to use as different objects.
  • Loading branch information
sciborrudnicki committed Sep 11, 2023
1 parent 847c2f0 commit df03e46
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
19 changes: 19 additions & 0 deletions object/_object.call.function.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Sass.
@use 'sass:meta';

// Modules.
@use '../object';

// Status: DONE
// The `object.call()` function calls `$function` with `$args`.
// @param `$name` A function
// @param `$function`
// @arbitrary `$args...`
// @returns The returned value is the result of executed `$function`.
@function call($name, $function, $args...) {
$-name: object.$name;
$debug: object.use($name);
$result: meta.call(meta.get-function($function, false, object), $args...);
$debug: object.use($-name);
@return $result;
}
60 changes: 60 additions & 0 deletions object/_object.wrapper.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Sass.
@use 'sass:meta';

// Variables.
$-function: null;

// Wrapper function for `object.copy()`.
@function copy($from, $to) {
@return meta.call($-function, copy, $from, $to);
}

// Wrapper function for `object.get()`.
@function get($key: null, $fallback: null) {
@return meta.call($-function, get, $key, $fallback);
}

// Wrapper function for `object.has-key()`.
@function has-key($key, $keys...) {
@return meta.call($-function, has-key, $key, $keys...);
}

// Wrapper function for `object.keys()`.
@function keys($key: null) {
@return meta.call($-function, keys, $key);
}

// Wrapper function for `object.last-id()`.
@function last-id() {
@return meta.call($-function, last-id);
}

// Wrapper function for `object.last-name()`.
@function last-name() {
@return meta.call($-function, last-name);
}

// Wrapper function for `object.merge()`.
@function merge($key: null, $objects...) {
@return meta.call($-function, merge, $key, $objects...);
}

// Wrapper function for `object.move()`.
@function move($from, $to) {
@return meta.call($-function, move, $from, $to);
}

// Wrapper function for `object.pick()`.
@function pick($key, $keys...) {
@return meta.call($-function, pick, $key, $keys...);
}

// Wrapper function for `object.remove()`.
@function remove($keys...) {
@return meta.call($-function, remove, $keys...);
}

// Wrapper function for `object.set()`.
@function set($key, $value, $allowed: ()) {
@return meta.call($-function, set, $key, $value, $allowed);
}

0 comments on commit df03e46

Please sign in to comment.