Skip to content

Commit

Permalink
feat(object.has-key()): add checking the key in any object name.
Browse files Browse the repository at this point in the history
  • Loading branch information
sciborrudnicki committed Sep 5, 2023
1 parent 112747d commit 25b7bff
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions object/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@forward 'object.create.function';
@forward 'object.get-key.function';
@forward 'object.get.function';
@forward 'object.has-key.function';
@forward 'object.keys.function';
@forward 'object.last-id.function';
@forward 'object.last-name.function';
Expand Down
22 changes: 22 additions & 0 deletions object/_object.has-key.function.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Sass.
@use 'sass:map';

// Variables.
@use 'object.var' as object;

// Functions.
@use 'object.get-key.function' as *;

// Status: TODO: key
// The `object.has-key()` function checks whether object in use has key.
// @param `$key` Required key to check object in use has.
// @arbitrary `$keys...` Additional keys to check nested key.
// @returns The returned value is a `bool` indicating object in use has key.
@function has-key($key, $keys...) {
@if type-of($key) == map {
@each $name, $key in $key {
@return map.has-key(object.$object, get-key($name, $key)...);
}
}
@return map.has-key(object.$object, get-key($key: $key)...);
}
3 changes: 3 additions & 0 deletions object/_object.spec.scss
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ $debug: object.merge(light, (object 1: 1), (object 2: 2));
// @debug object.get();
// @debug object.last-name();
// @debug object.keys();
// @debug object.has-key((theme: (light, theme color)));
// @debug object.has-key(light, theme color);

// @debug object.pick((light, dark color));

// $debug: object.copy(light, (dark color, theme)); // DONE
Expand Down

0 comments on commit 25b7bff

Please sign in to comment.