Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const x: Array> = attributes.map(logicalName => {
const existing = state[logicalName]
if (existing) return Maybe.Some(existing)
// get Dynamics attribute
const attribute = getAttribute(logicalName)
if (attribute) {
const token = ctx => onChangeHandler(logicalName, attribute.getValue())
attribute.addOnChange(token)
// set hasValue
const value = attribute.getValue()
const hasValue = attribute ? (value !== null) : false
return Maybe.Some({
name: logicalName, logicalName, attribute, hasValue, unregisterToken: token, value,
} as Attribute)
}
else {
// throw an error?
if (DEBUG) console.log("connect: Unable to connect:", logicalName)
return Maybe.None>()
// get Dynamics attribute
const attribute = getAttribute(logicalName)
if (attribute) {
const token = ctx => onChangeHandler(logicalName, attribute.getValue())
attribute.addOnChange(token)
// set hasValue
const value = attribute.getValue()
const hasValue = attribute ? (value !== null) : false
return Maybe.Some({
name: logicalName, logicalName, attribute, hasValue, unregisterToken: token, value,
} as Attribute)
}
else {
// throw an error?
if (DEBUG) console.log("connect: Unable to connect:", logicalName)
return Maybe.None>()
}
}).filter(aOpt => aOpt.isSome()).map(aOpt => aOpt.some())
return { ...state, ...normalizeWith("logicalName", x) }
protected handleChange = (id: string, value: any): void => {
if (DEBUG) console.log(`${NAME}.handleChange: id: `, id, "value: ", value)
this.setState({
buffer: this.state.buffer.map(b => ({ ...b, [id]: value }))
// @ts-ignore: buffer is copy and more!, actually this should never happen!
.orElse(Maybe.pure({ [id]: value })),
changed: [id, ...this.state.changed]
}, () => {
console.log(`${NAME}.handleChange: updated buffer is`, this.state.buffer, this.state.changed)
})
if (!this.props.isDirty) this.props.setDirty(true)
}
if (appMemberArr && appMemberArr.length) {
// lineage.push(get('state.configuration.applicationMember', plugin))
lineage = [...lineage, ...appMemberArr];
appPlugin = true;
}
// This is everything but application Plugins
// let r = Right(plugin.state).map((v) => {
//
// v.parents = lineage
// v.moduleSrc = moduleSrc
// v.namespace = ns
// v.loadSrc = loadSrc
// v.application = appPlugin
// return v
// })
let r = monet_1.Right(plugin).map((p) => {
p.loadMetadata = {
parents: lineage,
moduleSrc: moduleSrc,
namespace: ns,
loadSrc: loadSrc,
application: appPlugin
};
return p;
})
.cata(fail => {
throw fail;
}, fp_1.identity);
return [r];
});
})();
require('fantasy-land');
const { Future } = require('fluture');
const { Identity, Either } = require('monet');
const { MonetEitherT: EitherT } = require('monad-t');
const { FlutureTMonetEither: FutureTEither } = require('monad-t');
EitherT(Identity.of(1)); // => Either.Right(1)
FutureTEither.of(Future.of(Either.Right(1))); // => FlutureTMonetEither(1)
.bind(aspectRatio => Maybe.fromNull(
//
// Read out aspect ratio options and filter them
//
values(options).filter(o => o && (o.width / o.height).toFixed(2) === aspectRatio.toFixed(2))[0]
))
.map(o => new ConfiguredAspectRatioStrategy(o.width, o.height, o.label))
constructor(props) {
super(props)
this.state = {
items: [],
selected: Maybe.None(),
buffer: Maybe.None(),
changed: [],
}
this.selection = new Selection({
onSelectionChanged: this.onSelectionChanged,
// only used on setItems, so useless in restricting selection
//canSelectItem: this.canSelectItem,
})
}
private selection: ISelection
constructor(props) {
super(props)
this.state = {
items: [],
selected: Maybe.None(),
buffer: Maybe.None(),
changed: [],
}
this.selection = new Selection({
onSelectionChanged: this.onSelectionChanged,
// only used on setItems, so useless in restricting selection
//canSelectItem: this.canSelectItem,
})
}
private selection: ISelection
export const osmStateShred: OsmStateShredType = ([state, log]) => {
const newState = Identity(setClone(logGetEveryId(log)))
.map(idsToSave => setAddIterable(logGetBaseIds(log), idsToSave))
.map(idsToSave => expandIdsAndRelated(idsToSave, state.getElementTable()))
.map(entityTable => State.create(entityTable))
.get();
// @TOFIX reliance on ''
newState.getQuadkeysTable().set('', setClone(logGetEveryId(log)));
return [newState, log];
};
get aspectRatioDimensions() {
const {width, height} = this.aspectRatioStrategy;
return width && height ? Some({width, height}) : None();// eslint-disable-line babel/new-cap
}