Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@produck/charon-options

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@produck/charon-options - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

4

package.json
{
"name": "@produck/charon-options",
"version": "0.1.1",
"version": "0.2.0",
"description": "Reactive options accessor provider.",

@@ -38,3 +38,3 @@ "keywords": [

},
"gitHead": "7f589c264ffa8f5cb6c846f709a3cefab83dcefd"
"gitHead": "281fe20e7dc0c3f6b1da4c3bb17270379828fae4"
}

@@ -5,2 +5,3 @@ import { Object, Lang, Console } from '@produck/charon';

const map = new WeakMap();
const constructorSet = new WeakSet();
const _ = getter => map.get(getter);

@@ -10,5 +11,15 @@

const assertAccessorConstructor = (any, name) => {
if (!constructorSet.has(any)) {
Lang.throwError(`Invalid child Accessor name="${name}".`);
}
};
export const define = (descriptor = {}, childAccessorMap = {}) => {
const finalDescriptor = Property.normalize(descriptor);
for (const name in childAccessorMap) {
assertAccessorConstructor(childAccessorMap[name], name);
}
function Raw() {

@@ -37,2 +48,11 @@ const raw = {};

static appendChild(name, ChildAccessor) {
if (childAccessorMap[name]) {
Lang.throwError('Conflict child accessor property name.');
}
assertAccessorConstructor(ChildAccessor, name);
childAccessorMap[name] = ChildAccessor;
}
static merge(accessor, source) {

@@ -55,2 +75,4 @@ if (!Lang.instanceOf(accessor, CustomAccessor)) {

constructorSet.add(CustomAccessor);
for (const propertyName in finalDescriptor) {

@@ -57,0 +79,0 @@ Object.defineProperty(CustomAccessor.prototype, propertyName, {

interface BaseAccessor {}
interface AccessorConstructor<
export interface AccessorConstructor<
Descriptor extends BaseDescriptor = {},

@@ -13,2 +13,4 @@ ChildrenAccessorConstructorMap extends AccessorConstructorMap = {},

appendChild(name: string, ChildAccessor: AccessorConstructor): void;
merge(

@@ -41,4 +43,4 @@ accessor: MixinedAccessor<Descriptor, ChildrenAccessorConstructorMap>,

type MixinedAccessor<
Descriptor extends BaseDescriptor = BaseDescriptor,
ChildrenAccessorConstructorMap extends AccessorConstructorMap = AccessorConstructorMap
Descriptor extends BaseDescriptor = {},
ChildrenAccessorConstructorMap extends AccessorConstructorMap = {}
> = BaseAccessor & {

@@ -53,8 +55,14 @@ [SelfProperty in keyof Descriptor]:

export function define<
CustomDescriptor extends BaseDescriptor = BaseDescriptor,
ChildrenAccessorConstructorMap extends AccessorConstructorMap = AccessorConstructorMap
>(
descriptor?: CustomDescriptor,
children?: ChildrenAccessorConstructorMap
): AccessorConstructor<CustomDescriptor, ChildrenAccessorConstructorMap>;
export interface OptionsConstructorProvider<
Context = any
> {
<
CustomDescriptor extends BaseDescriptor = {},
ChildrenAccessorConstructorMap extends AccessorConstructorMap = {}
> (
descriptor?: CustomDescriptor,
children?: ChildrenAccessorConstructorMap
): AccessorConstructor<CustomDescriptor, ChildrenAccessorConstructorMap>;
}
export const define: OptionsConstructorProvider;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc