Skip to content

Commit

Permalink
Merge pull request #6 from aedart/add-concerns
Browse files Browse the repository at this point in the history
Add concerns
  • Loading branch information
aedart committed Mar 5, 2024
2 parents ab4e4d2 + 086f951 commit 00d2163
Show file tree
Hide file tree
Showing 268 changed files with 15,490 additions and 1,179 deletions.
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,43 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

* Concerns - an alternative to mixins, in `@aedart/contracts/support/concerns`.
* `@aedart/contracts/support/exceptions` and `@aedart/support/exceptions` submodules.
* `@aedart/contracts/support/objects` submodule.
* `@aedart/contracts/support/arrays` and `@aedart/support/arrays` submodules.
* `ConcatSpreadable` (_extends TypeScript's `ArrayLike` interface_) interface in `@aedart/contracts/support/arrays`.
* `Throwable` (_extends TypeScript's `Error` interface_) interface in `@aedart/contracts/support/exceptions`.
* `Cloneable` and `Populatable` interfaces in `@aedart/contracts/support/objects`.
* `LogicalError` and `AbstractClassError` exceptions in `@aedart/support/exceptions`.
* `getErrorMessage()`, `configureCustomError()` and `configureStackTrace()` in `@aedart/support/exceptions`.
* `FUNCTION_PROTOTYPE` and `TYPED_ARRAY_PROTOTYPE` constants in `@aedart/contracts/support/reflections`.
* `ClassBlueprint` interface in `@aedart/contracts/support/reflections`.
* `DANGEROUS_PROPERTIES` constant in `@aedart/contracts/support/objects`.
* `hasPrototypeProperty()` and `assertHasPrototypeProperty()` in `@aedart/support/reflections`.
* `getParentOfClass()` and `getAllParentsOfClass()` in `@aedart/support/reflections`.
* `getClassPropertyDescriptor()` and `getClassPropertyDescriptors()` in `@aedart/support/reflections`.
* `isWeakKind()` in `@aedart/support/reflections`.
* `isKeySafe()` and `isKeyUnsafe()` in `@aedart/support/reflections`.
* `getConstructorName()` and `getNameOrDesc()` in `@aedart/support/reflections`.
* `isSubclass()`, `classLooksLike()`, `isSubclassOrLooksLike()`, `classOwnKeys()`, `hasMethod()` and `hasAllMethods()` in `@aedart/support/reflections`.
* `merge()`, `populate()`, `isCloneable()` and `isPopulatable()` in `@aedart/support/objects`.
* Objects `Merger` (_underlying component for the objects `merge()` util_) in `@aedart/support/objects`.
* `merge()`, `isTypedArray()`, `isArrayLike()`, `isSafeArrayLike()`, `isTypedArray()` and `isConcatSpreadable()` in `@aedart/support/arrays`.
* `includesAny()` and `includesAll()` in `@aedart/support/arrays`.

### Changed

* Split the "support" submodules docs into several smaller pages.

### Fixed

* Lodash JSDoc references in `get()`, `set()`, `unset()` and `forget()`, in `@aedart/support/objects`.
* `jasmine-core` `v4.x` was used by `karma-jasmine`, which caused thrown exceptions that contained `ErrorOptions` to not being rendered correctly in the CLI. [_See GitHub issue for details_](https://github.com/jasmine/jasmine/issues/2028).
* Default `defaultTheme` deprecated, replaced with named import, in docs `config.ts`.
* `defineClientConfig()` does not exist in docs `client.ts` (_replaced with an object of the type `ClientConfig`_).

## [0.8.0] - 2024-02-12

### Added
Expand Down
4 changes: 4 additions & 0 deletions aliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ module.exports = {

alias: {
// contracts
'@aedart/contracts/support/arrays': path.resolve(__dirname, './packages/contracts/support/arrays'),
'@aedart/contracts/support/concerns': path.resolve(__dirname, './packages/contracts/support/concerns'),
'@aedart/contracts/support/exceptions': path.resolve(__dirname, './packages/contracts/support/exceptions'),
'@aedart/contracts/support/meta': path.resolve(__dirname, './packages/contracts/support/meta'),
'@aedart/contracts/support/mixins': path.resolve(__dirname, './packages/contracts/support/mixins'),
'@aedart/contracts/support/objects': path.resolve(__dirname, './packages/contracts/support/objects'),
'@aedart/contracts/support/reflections': path.resolve(__dirname, './packages/contracts/support/reflections'),
'@aedart/contracts/support': path.resolve(__dirname, './packages/contracts/support'),
'@aedart/contracts': path.resolve(__dirname, './packages/contracts/src'),
Expand Down
133 changes: 128 additions & 5 deletions docs/.vuepress/archive/Version0x.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,134 @@ export default PagesCollection.make('v0.x', '/v0x', [
children: [
'packages/support/',
'packages/support/install',
'packages/support/mixins',
'packages/support/meta',
'packages/support/objects',
'packages/support/reflections',
'packages/support/misc',
{
text: 'Arrays',
collapsible: true,
children: [
'packages/support/arrays/',
'packages/support/arrays/includesAll',
'packages/support/arrays/includesAny',
'packages/support/arrays/isArrayLike',
'packages/support/arrays/isConcatSpreadable',
'packages/support/arrays/isSafeArrayLike',
'packages/support/arrays/isTypedArray',
'packages/support/arrays/merge',
]
},
{
text: 'Concerns',
collapsible: true,
children: [
'packages/support/concerns/',
'packages/support/concerns/prerequisites',
'packages/support/concerns/concernClass',
'packages/support/concerns/usage',
'packages/support/concerns/aliases',
'packages/support/concerns/conflictResolution',
'packages/support/concerns/booting',
'packages/support/concerns/hooks',
'packages/support/concerns/edgeCases',
'packages/support/concerns/jsdoc',
]
},
{
text: 'Exceptions',
collapsible: true,
children: [
'packages/support/exceptions/',
'packages/support/exceptions/configureCustomError',
'packages/support/exceptions/configureStackTrace',
'packages/support/exceptions/getErrorMessage',
'packages/support/exceptions/customErrors',
]
},
{
text: 'Meta',
collapsible: true,
children: [
'packages/support/meta/',
'packages/support/meta/prerequisites',
'packages/support/meta/supported',
'packages/support/meta/setAndGet',
'packages/support/meta/inheritance',
'packages/support/meta/outsideChanges',
'packages/support/meta/tc39',
'packages/support/meta/targetMeta',
]
},
{
text: 'Mixins',
collapsible: true,
children: [
'packages/support/mixins/',
'packages/support/mixins/newMixin',
'packages/support/mixins/apply',
'packages/support/mixins/instanceof',
'packages/support/mixins/inheritance',
'packages/support/mixins/onward',
]
},
{
text: 'Object',
collapsible: true,
children: [
'packages/support/objects/',
'packages/support/objects/forget',
'packages/support/objects/forgetAll',
'packages/support/objects/get',
'packages/support/objects/has',
'packages/support/objects/hasAll',
'packages/support/objects/hasAny',
'packages/support/objects/hasUniqueId',
'packages/support/objects/isCloneable',
'packages/support/objects/isPopulatable',
'packages/support/objects/isset',
'packages/support/objects/merge',
'packages/support/objects/populate',
'packages/support/objects/set',
'packages/support/objects/uniqueId',
]
},
{
text: 'Reflections',
collapsible: true,
children: [
'packages/support/reflections/',
'packages/support/reflections/assertHasPrototypeProperty',
'packages/support/reflections/classLooksLike',
'packages/support/reflections/classOwnKeys',
'packages/support/reflections/getAllParentsOfClass',
'packages/support/reflections/getClassPropertyDescriptor',
'packages/support/reflections/getClassPropertyDescriptors',
'packages/support/reflections/getConstructorName',
'packages/support/reflections/getNameOrDesc',
'packages/support/reflections/getParentOfClass',
'packages/support/reflections/hasAllMethods',
'packages/support/reflections/hasMethod',
'packages/support/reflections/hasPrototypeProperty',
'packages/support/reflections/isConstructor',
'packages/support/reflections/isKeySafe',
'packages/support/reflections/isKeyUnsafe',
'packages/support/reflections/isSubclass',
'packages/support/reflections/isSubclassOrLooksLike',
'packages/support/reflections/isWeakKind',
]
},
{
text: 'Misc',
collapsible: true,
children: [
'packages/support/misc/',
'packages/support/misc/descTag',
'packages/support/misc/empty',
'packages/support/misc/isKey',
'packages/support/misc/isPrimitive',
'packages/support/misc/isPropertyKey',
'packages/support/misc/isset',
'packages/support/misc/mergeKeys',
'packages/support/misc/toWeakRef',
]
},
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions docs/.vuepress/client.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { defineClientConfig } from '@vuepress/client';
import type { ClientConfig } from '@vuepress/client';
// @ts-ignore
import Layout from "./layouts/Layout.vue";

export default defineClientConfig({
export default {
enhance({ app, router, siteData }) {},
setup() {},
rootComponents: [],
layouts: {
Layout
}
})
} as ClientConfig;
2 changes: 1 addition & 1 deletion docs/.vuepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {defineUserConfig, Page} from 'vuepress';
import defaultTheme from "@vuepress/theme-default"
import { defaultTheme } from "@vuepress/theme-default"
import { webpackBundler } from "@vuepress/bundler-webpack"
import {backToTopPlugin} from "@vuepress/plugin-back-to-top";
import {searchPlugin} from "@vuepress/plugin-search";
Expand Down
53 changes: 49 additions & 4 deletions docs/archive/current/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sidebarDepth: 0

::: danger
Ion is still in development.
You _SHOULD NOT_ use any of the packages in production.
You _SHOULD NOT_ use any of the packages in a production environment.
Breaking changes _**MUST**_ be expected for all `v0.x` releases!

_Please review the [`CHANGELOG.md`](https://github.com/aedart/ion/blob/main/CHANGELOG.md) for additional details._
Expand All @@ -29,6 +29,51 @@ _TBD: "To be decided"._

## `v0.x` Highlights

### Concerns <Badge type="tip" text="Available since v0.9" />

Intended as an alternative to mixins, the [Concerns](./packages/support/concerns/README.md) submodule offers a different
way to overcome some of the limitations of single inheritance.

```js
import { use, AbstractConcern } from "@aedart/support/concerns";

// A concern class...
class Role extends AbstractConcern {
addRole(name) {
/* ...not shown... */
}
}

// Use concern in target class...
@use(Role)
class User {}

// Later in your application...
const user = new User();
user.addRole('maintainer');
user.addRole('supporter');
```

### Merge <Badge type="tip" text="Available since v0.9" />

Objects [merge](./packages/support/objects/merge.md) utility, using [deep copy](https://developer.mozilla.org/en-US/docs/Glossary/Deep_copy).

```js
import { merge } from "@aedart/support/objects";

const a = {
'name': 'Alin',
};

const b = {
'address': {
'street': 'Northern Street 1'
},
};

const result = merge(a, b); // { 'name': 'Alin', 'address': { 'street': '...' } }
```

### Mixins <Badge type="tip" text="Available since v0.8" />

Adaptation of Justin Fagnani's [`mixwith.js`](https://github.com/justinfagnani/mixwith.js).
Expand Down Expand Up @@ -59,12 +104,12 @@ item.name = 'My Item';
console.log(item.name); // My Item
```

See details and more examples in the [`@aedart/support/mixins` documentation](./packages/support/mixins.md).
See details and more examples in the [`@aedart/support/mixins` documentation](./packages/support/mixins/README.md).

### "Target" Meta Decorator <Badge type="tip" text="Available since v0.7" />

Associate arbitrary metadata directly with the target element that is being decorated.
_See [target meta decorator](./packages/support/meta.md) fro additional details._
_See [target meta decorator](./packages/support/meta/targetMeta.md) fro additional details._

```js
import {targetMeta, getTargetMeta} from '@aedart/support/meta';
Expand All @@ -85,7 +130,7 @@ getTargetMeta(instance.search, 'desc'); // Seaches for cities

### Meta Decorator <Badge type="tip" text="Available since v0.6" />

The [meta decorator](./packages/support/meta.md) is able to associate arbitrary metadata with a class and its elements.
The [meta decorator](./packages/support/meta/README.md) is able to associate arbitrary metadata with a class and its elements.

```js
import {meta, getMeta} from '@aedart/support/meta';
Expand Down
8 changes: 8 additions & 0 deletions docs/archive/current/packages/support/arrays/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: About Arrays
description: Array utilities.
---

# About Arrays <Badge type="tip" text="Available since v0.9" vertical="middle" />

`@aedart/support/arrays` contains [array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) related utilities.
18 changes: 18 additions & 0 deletions docs/archive/current/packages/support/arrays/includesAll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: Includes All
description: Determine if array contains all values.
sidebarDepth: 0
---

# `includesAll`

Determines if an array includes all values.

```js
import { includesAll } from '@aedart/support/arrays';

const arr = [ 1, 2, 3 ];

includesAll(arr, [ 1, 2 ]); // true
includesAll(arr, [ 1, 4 ]); // false
```
18 changes: 18 additions & 0 deletions docs/archive/current/packages/support/arrays/includesAny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: Includes Any
description: Determine if array contains some values.
sidebarDepth: 0
---

# `includesAny`

Determines if an array includes some values.

```js
import { includesAny } from '@aedart/support/arrays';

const arr = [ 1, 2, 3 ];

includesAll(arr, [ 4, 2 ]); // true
includesAll(arr, [ 5, 5 ]); // false
```
30 changes: 30 additions & 0 deletions docs/archive/current/packages/support/arrays/isArrayLike.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: Is Array Like
description: Determine if value is array-like.
sidebarDepth: 0
---

# `isArrayLike`

Determines if a value is ["array-like"](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#array-like_objects).

(_`isArrayLike()` is an alias for Lodash's [isArrayLike](https://lodash.com/docs/4.17.15#isArrayLike)._)

```js
import { isArrayLike } from '@aedart/support/arrays';

isArrayLike([]); // true
isArrayLike('abc'); // true
isArrayLike(new String('abc')); // true
isArrayLike({ length: 0 }); // true
isArrayLike(new Int8Array()); // true

isArrayLike({}); // false
isArrayLike(function() {}); // false
isArrayLike(new Boolean(true)); // false
isArrayLike(123); // false
isArrayLike(new Number(123)); // false
// ...etc
```

See also [_`isSafeArrayLike()`_](./issafearraylike.md).
Loading

0 comments on commit 00d2163

Please sign in to comment.