-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(object.wrapper): add wrapper functions in combination with `obje…
…ct.call()` function to use as different objects.
- Loading branch information
1 parent
847c2f0
commit df03e46
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |