Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "fluids", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Glue layer for reactivity", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -1,6 +0,12 @@ | ||
/** Access the internal config for observing a `FluidValue` object. */ | ||
export declare function getFluidConfig<T, Event extends FluidEvent<T>>(arg: FluidValue<T, Event>): FluidConfig<T, Event>; | ||
export declare function getFluidConfig(arg: any): FluidConfig | undefined; | ||
/** Set the internal config for observing a `FluidValue` object. */ | ||
export declare function setFluidConfig(target: object, config: FluidConfig): void; | ||
export { hasFluidValue, getFluidValue, getFluidConfig, setFluidConfig }; | ||
/** Does the given value have a `FluidConfig` object? */ | ||
declare const hasFluidValue: (arg: any) => arg is FluidValue<any, any>; | ||
declare type GetFluidValue<T> = T extends FluidValue<infer U> ? U : T; | ||
/** Get the current value of a fluid object. Returns the first argument when it's not a fluid object. */ | ||
declare function getFluidValue<T>(target: T): GetFluidValue<T>; | ||
declare type GetFluidConfig<T> = T extends FluidValue<infer U, infer E> ? FluidConfig<U, E> : undefined; | ||
/** Get the methods for observing the given object. Returns undefined if not a fluid object. */ | ||
declare function getFluidConfig<T>(arg: T): GetFluidConfig<T>; | ||
/** Set the methods for observing the given object. */ | ||
declare function setFluidConfig(target: object, config: FluidConfig): void; | ||
export interface ChangeEvent<T = any> { | ||
@@ -7,0 +13,0 @@ type: 'change'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var $config = Symbol.for('FluidValue:config'); | ||
/** Does the given value have a `FluidConfig` object? */ | ||
var hasFluidValue = function (arg) { return !!getFluidConfig(arg); }; | ||
exports.hasFluidValue = hasFluidValue; | ||
function getFluidValue(arg) { | ||
var config = getFluidConfig(arg); | ||
return config ? config.get() : arg; | ||
} | ||
exports.getFluidValue = getFluidValue; | ||
function getFluidConfig(arg) { | ||
@@ -9,3 +17,3 @@ if (arg) | ||
exports.getFluidConfig = getFluidConfig; | ||
/** Set the internal config for observing a `FluidValue` object. */ | ||
/** Set the methods for observing the given object. */ | ||
function setFluidConfig(target, config) { | ||
@@ -12,0 +20,0 @@ Object.defineProperty(target, $config, { value: config }); |
const $config = Symbol.for('FluidValue:config') | ||
/** Access the internal config for observing a `FluidValue` object. */ | ||
export function getFluidConfig<T, Event extends FluidEvent<T>>( | ||
arg: FluidValue<T, Event> | ||
): FluidConfig<T, Event> | ||
export function getFluidConfig(arg: any): FluidConfig | undefined | ||
export function getFluidConfig(arg: any): FluidConfig | undefined { | ||
export { hasFluidValue, getFluidValue, getFluidConfig, setFluidConfig } | ||
/** Does the given value have a `FluidConfig` object? */ | ||
const hasFluidValue = (arg: any): arg is FluidValue => !!getFluidConfig(arg) | ||
type GetFluidValue<T> = T extends FluidValue<infer U> ? U : T | ||
/** Get the current value of a fluid object. Returns the first argument when it's not a fluid object. */ | ||
function getFluidValue<T>(target: T): GetFluidValue<T> | ||
function getFluidValue(arg: any) { | ||
const config = getFluidConfig(arg) | ||
return config ? config.get() : arg | ||
} | ||
type GetFluidConfig<T> = T extends FluidValue<infer U, infer E> | ||
? FluidConfig<U, E> | ||
: undefined | ||
/** Get the methods for observing the given object. Returns undefined if not a fluid object. */ | ||
function getFluidConfig<T>(arg: T): GetFluidConfig<T> | ||
function getFluidConfig(arg: any) { | ||
if (arg) return arg[$config] | ||
} | ||
/** Set the internal config for observing a `FluidValue` object. */ | ||
export function setFluidConfig(target: object, config: FluidConfig) { | ||
/** Set the methods for observing the given object. */ | ||
function setFluidConfig(target: object, config: FluidConfig) { | ||
Object.defineProperty(target, $config, { value: config }) | ||
@@ -15,0 +30,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7097
141