From df03e46bdca5c4384d4a3fd281f798d8fa68343e Mon Sep 17 00:00:00 2001 From: angularpackage Date: Mon, 11 Sep 2023 23:05:22 +0000 Subject: [PATCH] feat(object.wrapper): add wrapper functions in combination with `object.call()` function to use as different objects. --- object/_object.call.function.scss | 19 ++++++++++ object/_object.wrapper.scss | 60 +++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 object/_object.call.function.scss create mode 100644 object/_object.wrapper.scss diff --git a/object/_object.call.function.scss b/object/_object.call.function.scss new file mode 100644 index 0000000..02bf605 --- /dev/null +++ b/object/_object.call.function.scss @@ -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; +} diff --git a/object/_object.wrapper.scss b/object/_object.wrapper.scss new file mode 100644 index 0000000..70c91c5 --- /dev/null +++ b/object/_object.wrapper.scss @@ -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); +}