Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor (props) {
this.props = Object.assign({}, this.defaultProps, props);
assert(/^(\d|[a-f]){40}$/i.test(this.props.infoHash));
if (!this.props._id) {
this.props._id = shortid.generate();
}
}
getData() {
forOwn(endpoints, endpoint => {
let duplicatedEndpoint = find(modifiedEndpoints, val => {
return endpoint.url === val.url;
});
if (!duplicatedEndpoint) {
const key = shortid.generate();
endpoint.key = key;
modifiedEndpoints[key] = endpoint;
} else {
ObjectAssign(duplicatedEndpoint, endpoint);
}
});
update.prototype.uuid = function() {
var self = this;
var uuid = shortid.generate();
if (fs.existsSync(self.cfgdir + 'machid')) {
var text = "";
try {
text = fs.readFileSync(self.cfgdir + 'machid');
if (text) {
uuid = text.toString();
debug('read uuid', uuid);
}
} catch(e) {
debug('error reading uuid-file', e);
}
}
else {
debug('creating uuid file');
fs.writeFileSync(self.cfgdir + 'machid', uuid);
addField() {
this.props.addSubelement({id : this.props.id, 'path' : ['content','collectable_fields'], 'default' : {'_id': shortid.generate(), 'type' : 'text', content : {'message' : '', 'name' : '', 'validation' : '', 'field' : ''}}});
}
componentWillMount () {
this.generatedId = shortid.generate();
},
const http = require('http');
const bodyParser = require('body-parser');
const { graphqlExpress, graphiqlExpress } = require('apollo-server-express');
const { makeExecutableSchema } = require('graphql-tools');
const { PubSub, withFilter } = require('graphql-subscriptions');
const { SubscriptionServer } = require('subscriptions-transport-ws');
const { execute, subscribe } = require('graphql');
const shortid = require('shortid');
const casual = require('casual');
const cors = require('cors');
const pubsub = new PubSub();
const orgId = shortid.generate();
const locationId1 = shortid.generate();
const locationId2 = shortid.generate();
const db = {
locations: [{ id: locationId1, orgId, name: casual.address2 }, { id: locationId2, orgId, name: casual.address2 }],
users: [
{
id: shortid.generate(),
name: casual.name,
email: casual.email,
orgId: null,
locationId: locationId1,
userType: 'ZELO'
},
{ id: shortid.generate(), name: casual.name, email: casual.email, orgId, locationId: null, userType: 'ZEWI' },
{ id: shortid.generate(), name: casual.name, email: casual.email, orgId, locationId: null, userType: 'ZOWI' }
],
comments: [
getInitialState() {
return {
tasks: [{
id: id(),
content: "Update CSS styles",
complete: false
}, {
id: id(),
content: "Add unit tests",
complete: false
}, {
id: id(),
content: "Post to social media",
complete: false
},{
id: id(),
content: "Install hard drive",
complete: true
}],
showComplete:true
function generateData(): IDb {
const books: IBook[] = [];
const users: IUser[] = [];
for (let i: number = 0; i < 2; i++) {
const user: IUser = { id: shortid.generate(), name: casual.name };
users.push(user);
}
for (let i: number = 0; i < 10; i++) {
const ranInt: number = getRandomInt(0, users.length - 1);
const { id: authorId }: { id: string } = users[ranInt];
const book: IBook = { id: shortid.generate(), title: casual.title, authorId };
books.push(book);
}
return { books, users };
}
function buildComponentTreeFromConfig( componentConfig, childProps = {} ) {
const { id, componentType, children, props, partial } = componentConfig;
if ( partial ) {
return buildComponentTreeFromConfig( getPartialByType( partial ), childProps );
}
const componentId = id || shortid.generate();
const Component = getComponentByType( componentType );
const childComponents = children ? children.map( child => buildComponentTreeFromConfig( child, childProps ) ) : null;
const componentProps = Object.assign(
{},
props || {},
{ childProps },
{ className: classNames( componentType, componentId ), key: componentId }
);
return { Component, componentId, componentProps, childComponents, componentType };
}