Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private addPolygonLabel(polygon: IPoint[]) {
// todo: to be removed
const activeLabelIndex = LabelsSelector.getActiveLabelNameIndex();
const activeLabelId = LabelsSelector.getActiveLabelId();
const imageData: ImageData = LabelsSelector.getActiveImageData();
const labelPolygon: LabelPolygon = {
id: uuidv1(),
labelIndex: activeLabelIndex,
labelId: activeLabelId,
vertices: polygon
};
imageData.labelPolygons.push(labelPolygon);
store.dispatch(updateImageDataById(imageData.id, imageData));
store.dispatch(updateFirstLabelCreatedFlag(true));
store.dispatch(updateActiveLabelId(labelPolygon.id));
};
export const getChartConfig = ({
type,
data,
config,
onclick,
id = uuidV1(),
}) => {
const chartConfigForType = chartsSizeConfig[type][config];
const colors = getColors(data);
const colorsSize = Object.keys(colors).length;
const dataExists = doDataExist(data);
const longNames = [];
const shortNames = [];
let dataWithShortNames = [];
if (dataExists) {
dataWithShortNames = data.map(val => {
const item = Immutable.asMutable(val.slice());
longNames.push(item[0]);
item[0] = item[0].length > 30 ? `${val[0].substring(0, 10)}...` : item[0];
shortNames.push(item[0]);
export function createSong(args) {
const params = {
TableName,
Item: {
id: uuid(),
title: args.title,
artist: args.artist,
duration: args.duration,
},
};
return db.createItem(params);
}
selectContact = (name, i, matches) => {
const contact = matches[i];
const selected = this.state.selected.slice();
selected.push({ label: name, avatar: contact.leftAvatar, key: guid() });
this.setState({ selected });
};
addTodo () {
const value = this.newTodo && this.newTodo.trim()
if (!value) return
this.todos.push({
id: uuidv1(),
title: value,
completed: false,
})
this.newTodo = ''
},
removeTodo (todo) {
.then(async picture => {
picture = await this.rotateImageBasedOnOrientation(picture);
const fileOptions: IWriteOptions = {
replace: true
};
this.file.writeFile(this.file.cacheDirectory, uuid() + '.jpeg', base64toBlob(picture, 'image/jpeg'), fileOptions)
.then(fileEntry => {
const normalizedURL = normalizeURL(fileEntry.toURL());
this.pictures.push({
fileEntry,
normalizedURL,
base64Data: picture
});
})
.catch(err => {
this.errorHandler(err);
});
})
.catch(err => {
s.forEach(source => {
const descriptor = {
id: !source.id ? uuidv1() : source.id,
meta: {
label: source.description || 'User defined',
},
kind: sources.kinds.user_defined,
sdp: {
streams: [
{
dstAddr: source.dstAddr,
dstPort: parseInt(source.dstPort, 10),
},
],
},
};
api.addLiveSource(descriptor)
.then(() => {
input.onchange = () => {
const files = input.files;
const retFiles = [];
for (let i = 0; i < files.length; ++i) {
const uuid = uuidv1();
const url = URL.createObjectURL(files[i]);
presentation.assets.set(uuid, url);
retFiles.push(uuid);
}
resolve({
files: retFiles
});
};
input.click();
onButtonPress = () => {
const {date} = this.state;
const id = uuid();
this.props.addNew(date, id);
}
componentDidMount () {
const priceSubsription$ = stub
.subscribeToTopic('prices')
.pipe(
map(price=>convertToPrice(price)),
savePrices)
.subscribe(newPrices => {
latest = newPrices
})
const session$ = connection$.pipe(
filter((connection): connection is ConnectionOpenEvent => connection.type === ConnectionEventType.CONNECTED),
map(connection => connection.session),
)
const HOST_TYPE = 'priceHistory'
const hostInstance = `${HOST_TYPE}.${uuid().substring(0, 4)}`
logger.info(`Starting heart beat with ${HOST_TYPE} and ${hostInstance}`)
const heartbeat$ = session$.pipe(switchMap(session => interval(1000).pipe(mapTo(session)))).subscribe(session => {
const status: RawServiceStatus = {
Type: 'priceHistory',
Load: 1,
TimeStamp: Date.now(),
Instance: hostInstance,
}
session.publish('status', [status])
})
type PriceHistoryRequest = [{ payload: string }]
session$.subscribe(session => {