Skip to content

Commit ef052aa

Browse files
Merge pull request #18 from angular-package/develop
v0.8.0-beta
2 parents c93aa02 + fe197fb commit ef052aa

29 files changed

+380
-335
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# @angular-package/sass changelog
22

3+
### v0.8.0-beta [#](https://github.com/angular-package/sass/releases/tag/v0.8.0-beta)
4+
5+
- Add [`object.destroy()`](https://github.com/angular-package/sass/blob/main/object/_object.destroy.function.scss) to remove object name. [127c5e4]
6+
- Update [`translator/dictionary`](https://github.com/angular-package/sass/tree/main/translator/v1.0.0/dictionary) module to use `object` module. [ae50b2a]
7+
- Update [`object.set()`](https://github.com/angular-package/sass/blob/main/object/_object.set.function.scss) function to return `$name` on `$name` equal to it `object.$object`. [3e2f9b8]
8+
- Add [`object.has-key()`](https://github.com/angular-package/sass/blob/main/object/_object.has-key.function.scss) function to check the key in any object. [25b7bff]
9+
- Add [`object.get-key()`](https://github.com/angular-package/sass/blob/main/object/_object.get-key.function.scss) function to get key object of `$name` and `$key`. [c05d520] [112747d]
10+
11+
[3e2f9b8]: https://github.com/angular-package/sass/pull/18/commits/3e2f9b8569d98d9f9baa5b1319f62a0ccad58d8a
12+
[127c5e4]: https://github.com/angular-package/sass/commit/127c5e4235ca08608a7889cc67c6872eea03509f
13+
[ae50b2a]: https://github.com/angular-package/sass/commit/ae50b2a9cdf76d8791aeebe93ef4c5def16b11c8
14+
[25b7bff]: https://github.com/angular-package/sass/commit/25b7bff9bfdce8b1399ced485aa015b74f72671f
15+
[112747d]: https://github.com/angular-package/sass/commit/112747d3b4baeac610f08e7fc0ec22cc7c40d5af
16+
[c05d520]: https://github.com/angular-package/sass/commit/c05d52067755dfdaf368e16164bb1ba9570592ed
17+
318
### v0.7.0-beta [#](https://github.com/angular-package/sass/releases/tag/v0.7.0-beta)
419

520
- Fix `map.set()` - add checking whether `$key` is comma-separated list to have ability to add space separated keys. [1d46564]

object/_index.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
@forward 'object.copy.function';
22
@forward 'object.create.function';
3+
@forward 'object.destroy.function';
4+
@forward 'object.get-key.function';
35
@forward 'object.get.function';
6+
@forward 'object.has-key.function';
47
@forward 'object.keys.function';
58
@forward 'object.last-id.function';
69
@forward 'object.last-name.function';

object/_object.copy.function.scss

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
1-
// Sass.
2-
@use 'sass:list';
3-
4-
// Variables.
5-
@use 'object.var' as object;
6-
7-
// Modules.
8-
@use '../map';
9-
101
// Functions.
112
@use 'object.get.function' as *;
123
@use 'object.set.function' as *;
13-
@use 'object.use.function' as *;
144

155
// Status: DONE
16-
// The `object.copy()` function.
17-
// @param `$from`
18-
// @param `$to`
19-
// @returns
6+
// The `object.copy()` function copies value from key `$from` to key `$to` of last created or selected object.
7+
// Copy values of different object names by providing map type (name: key). For example. (dictionary: class).
8+
// @param `$from` A key which from value is copied to key `$to`.
9+
// @param `$to` A key under which `$value` is pasted.
10+
// @returns The returned value is object with copied value from key `$from` to `$to`(if it's the same object).
2011
@function copy($from, $to) {
2112
@return set($to, get($from));
2213
}

object/_object.create.function.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// Status: DONE
1313
// The `object.create()` function sets `map` type object in `object.$object` variable under `$name` key.
1414
// @param `$object` A `map` type value to set in `object.$object` under `$name`.
15-
// @param `$name` The name under which `$object` of `map` type is stored, `null` indicates add new object under incremented `number`.
16-
// @returns The returned value is `$object` of `map` type under `$name` key of `object.$object`.
15+
// @param `$name` The name under which object of `map` type is stored, by default new object is stored under incremented `number`.
16+
// @returns The returned value is object of `map` type stored under `$name` key of `object.$object`.
1717
@function create($object, $name: list.length(object.$object) + 1) {
1818
$object: if(meta.type-of(list) and list.length($object) == 0, map.remove((1:1), 1), $object);
1919
@if type-of($object) == map {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Sass.
2+
@use 'sass:map';
3+
4+
// Object.
5+
@use 'object.var' as object;
6+
7+
// Functions.
8+
@use 'object.get.function' as *;
9+
@use 'object.last-name.function' as *;
10+
@use 'object.use.function' as *;
11+
12+
// Status: DONE
13+
// The `object.destroy()` function removes object(`map`) of `$name`.
14+
// @param `$name` Object name to remove.
15+
// @returns The returned value is last created object.
16+
@function destroy($name: object.$name or last-name()) {
17+
@if map.has-key(object.$object, $name) {
18+
$debug: use(null);
19+
object.$object: map.remove(object.$object, $name);
20+
}
21+
@return get();
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Sass.
2+
@use 'sass:list';
3+
4+
// Object.
5+
@use 'object.var' as object;
6+
7+
// Functions.
8+
@use '../list/list.insert-nth.function' as *;
9+
@use 'object.last-name.function' as *;
10+
11+
// Status: DONE
12+
// The `object.get-key()` function gets key object of `$name` and `$key`.
13+
// @param `$name` Object name, by default selected by `object.use()` or last object.
14+
// @param `$key` A key to retrieve from object of `$name`.
15+
// @returns The returned value is an object key of `$name` and `$key`.
16+
@function get-key($name: object.$name or last-name(), $key: null) {
17+
@return if(
18+
$key,
19+
insert-nth(if(list.separator($key) == comma, $key, ($key,)), 1, $name),
20+
$name
21+
);
22+
}

object/_object.get.function.scss

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
1-
// Sass.
2-
@use 'sass:list';
3-
41
// Object.
52
@use 'object.var' as object;
63

74
// Modules.
85
@use '../map';
96

107
// Functions.
11-
@use 'object.last-name.function' as *;
12-
@use 'object.use.function' as *;
8+
@use 'object.get-key.function' as *;
139

1410
// Status: DONE
15-
// The `object.get()` function gets `map` from `object.$object` variable of key `$name`, where by default is last created or set by `object.use()`.
16-
// @param `$key` An optional key of `map` from `object.$object` to get.
11+
// The `object.get()` function gets object, optionally value of this object retrieved from key.
12+
// To get the value from different object than in use pass `$key` as map where (name: key).
13+
// @param `$key` An optional key of object in use to get value, or object with key.
1714
// @param `$fallback` Fallback value if retrieved is `null`.
18-
// // @param `$name` A name of `map` in `object.$object` to get, `null` indicates last created object.
19-
// @returns The returned value is a `map` retrieved from `object.$object` of `$name`, optionally value retrieved from `$key`.
15+
// @returns The returned value is `map` from variable `object.$object`(optionally value from `$key`), by default from last created or set by `object.use()` object.
2016
@function get($key: null, $fallback: null) {
21-
$name: object.$name or last-name();
2217
@if type-of($key) == map {
2318
@each $name, $key in $key {
24-
@return map.get(object.$object, list.append($name, $key, comma), $fallback);
19+
@return map.get(object.$object, get-key($name, $key), $fallback);
2520
}
2621
}
27-
@return map.get(object.$object, if($key, list.append($name, $key, comma), $name), $fallback);
22+
@return map.get(object.$object, get-key($key: $key), $fallback);
2823
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Sass.
2+
@use 'sass:map';
3+
4+
// Variables.
5+
@use 'object.var' as object;
6+
7+
// Functions.
8+
@use 'object.get-key.function' as *;
9+
10+
// Status: TODO: key
11+
// The `object.has-key()` function checks whether object in use has key.
12+
// @param `$key` Required key to check object in use has.
13+
// @arbitrary `$keys...` Additional keys to check nested key.
14+
// @returns The returned value is a `bool` indicating object in use has key.
15+
@function has-key($key, $keys...) {
16+
@if type-of($key) == map {
17+
@each $name, $key in $key {
18+
@return map.has-key(object.$object, get-key($name, $key)...);
19+
}
20+
}
21+
@return map.has-key(object.$object, get-key($key: $key)...);
22+
}

object/_object.keys.function.scss

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
// Sass.
2-
@use 'sass:list';
32
@use 'sass:map';
43

54
// Object.
65
@use 'object.var' as object;
76

87
// Functions.
98
@use 'object.get.function' as *;
10-
@use 'object.last-name.function' as *;
119

1210
// Status: DONE
13-
// The `object.keys()` function.
14-
// @param `$key`
15-
// @returns
11+
// The `object.keys()` function gets the keys of object, optionally from value retrieved from `$key`.
12+
// @param `$key` An optional key of object, or object with key.
13+
// @returns The returned value is list of keys.
1614
@function keys($key: null) {
1715
@return map.keys(get($key));
1816
}

object/_object.last-id.function.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
@use 'object.var' as object;
77

88
// Status: DONE
9-
// The `object.last-id()` returns last object id.
10-
// @returns The returned value is of last added object.
9+
// The `object.last-id()` returns last created object number.
10+
// @returns The returned value is number of last created object.
1111
@function last-id() {
1212
@return list.length(map.keys(object.$object));
1313
}

0 commit comments

Comments
 (0)