Skip to content

Commit

Permalink
refactor(dictionary): use object wrapper functions and update spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
sciborrudnicki committed Sep 11, 2023
1 parent a349181 commit a68ed19
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 7 deletions.
72 changes: 67 additions & 5 deletions translator/v1.0.0/dictionary/_dictionary.core.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,70 @@
@forward '../../../object';
// Sass.
@use 'sass:meta';

// Modules.
@use '../../../object' as dictionary;
// Functions.
@forward 'dictionary.translation.function';
@use 'dictionary.call.function' as *;

// Variables.
$-function: meta.get-function(call, false);

// Object.
@use '../../../object';

// Initialize.
$debug: dictionary.create((), dictionary);
$debug: dictionary.use(dictionary);
$debug: object.create((), dictionary);

// 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);
}
8 changes: 6 additions & 2 deletions translator/v1.0.0/dictionary/_dictionary.spec.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
@use 'sass:map';

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

// @debug dictionary.merge('key', (test: 1));
// @debug object.$object;

// global dictionary defaults.
// dictionary.$dictionary: (
// prefix: spectre,
Expand All @@ -24,10 +28,10 @@ $-dictionary-example: (
);

// merge
@debug dictionary.merge(null, $-dictionary-example);
// @debug dictionary.merge(null, $-dictionary-example);

// Set the dictionary.
@debug dictionary.set(example, $-dictionary-example);
// @debug dictionary.set(example, $-dictionary-example);

// `get()`.
// @debug dictionary.get();
Expand Down

0 comments on commit a68ed19

Please sign in to comment.