How to use the cuid.slug function in cuid

To help you get started, we’ve selected a few cuid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keystonejs / keystone / test-projects / basic / cypress / integration / oembed_spec.js View on Github external
const saveValue = value => {
  cy.get(oembedInputSelector).clear();
  if (value) {
    cy.get(oembedInputSelector).type(value, { force: true });
  }
  const alias = cuid.slug();
  // Setup to track XHR requests
  cy.server();
  // Alias the graphql request route
  cy.route('post', '**/admin/api').as(alias);
  // Avoid accidentally mocking routes
  cy.server({ enable: false });
  cy.get('#item-page-save-button').click({ force: true });
  return cy.wait(`@${alias}`);
};
github TiE23 / metric-teacher / client / src / components / challenge / ChallengePage.js View on Github external
this.handleQuestionModeStart = () => {
      this.setState({
        questionModeStart: true,
        challengeId: cuid.slug(),
        selectedQuestionIds: [
          // Put question ids here.
          // Run by calling this function with a button click. Ideally in ChallengeKickoff.
        ],
      });
    };
  }
github scriptnull / compilex / cppModule.js View on Github external
exports.compileCPP = function ( envData ,  code , fn ) {
	//creating source file
	var filename = cuid.slug();
	path = './temp/';


	//create temp0
	fs.writeFile( path  +  filename +'.cpp' , code  , function(err ){
		if(exports.stats)
		{
			if(err)
				console.log('ERROR: '.red + err);
			else
			{
				console.log('INFO: '.green + filename +'.cpp created');
				//compiling and exrcuiting source code
				if(envData.cmd === 'g++')
				{
github scriptnull / compilex / cppModule.js View on Github external
exports.compileCPPWithInput = function ( envData , code , input ,  fn ) {
	var filename = cuid.slug();
	path = './temp/';

	//create temp0 
	fs.writeFile( path  +  filename +'.cpp' , code  , function(err ){
		if(exports.stats)
		{
			if(err)
				console.log('ERROR: '.red + err);
			else
			{
				console.log('INFO: '.green + filename +'.cpp created');
				if(envData.cmd ==='g++')
				{

					//compile c code
					commmand = 'g++ ' + path + filename +'.cpp -o '+ path + filename+'.exe' ;
github fiatjaf / filemap.xyz / app.js View on Github external
var filesToSave = {}

  if (e.target.password.value.trim()) {
    let password = e.target.password.value + '~' + SALT + '~' + name
    let w = SimpleEncryptor(password)

    for (let i = 0; i < queuedFiles.length; i++) {
      let {url, name} = queuedFiles[i]
      let encurl = w.encrypt(url)
      let encname = w.encrypt(name)
      filesToSave[cuid.slug()] = {url: encurl, name: encname}
    }

    for (let i = 0; i < validLinks.length; i++) {
      let encl = w.encrypt(validLinks[i])
      filesToSave[cuid.slug()] = {url: encl, name: encl}
    }
  } else {
    for (let i = 0; i < queuedFiles.length; i++) {
      let {url, name} = queuedFiles[i]
      filesToSave[cuid.slug()] = {url, name}
    }

    for (let i = 0; i < validLinks.length; i++) {
      let url = validLinks[i]
      filesToSave[cuid.slug()] = {url, name: url}
    }
  }

  filekeys
    .child(nextkey)
    .set({
github TiE23 / metric-teacher / client / src / components / question / QuestionViewer.js View on Github external
choices: this.props.qaData.answer.data.multiple.choices.map(choice => ({
                unit: choice.unit,
                mixedValue: choice.value || choice.written,
                cuid: cuid.slug(),
              })),
            } : null,
github lcofjp / visual-serial / src / js / serial / middlewareModal.js View on Github external
instanceByName(middlewareName) {
    const middleware = middlewareFactoryMap.get(middlewareName);
    const middlewareObject = {
      name: middlewareName,
      type: middleware.type,
      cuid: cuid.slug(),
      whichList: this.props.whichList,
    };
    if (middleware.type === 'protocol' || middleware.type === 'middleware') {
      const middlewareInstance = new middleware.factory();
      middlewareObject.instance = middlewareInstance;
    } else {
      middlewareObject.path = middleware.path;
    }
    return middlewareObject;
  }
github paulogr / dstatuspage / core.js View on Github external
async createIncident (incident) {
    if (!incident) {
      throw new Error('Incident is empty')
    }
    if (!incident.updates || incident.updates.length === 0) {
      throw new Error('Incident has no updates')
    }
    const id = `${slug(incident.title)}-${cuid.slug()}`.toLowerCase()
    const timestamp = new Date().toISOString()
    incident.id = id
    incident.createdAt = timestamp
    incident.status = incident.updates[0].status || incident.status
    incident.resolvedAt = incident.status === config.Statuses.RESOLVED ? timestamp : undefined
    incident.updates[0].status = incident.status
    incident.updates[0].updatedAt = timestamp
    const result = this.db.get('incidents').unshift(incident).write()
    if (!result[0].id) {
      throw new Error('Unable to create incident.')
    }
    this.db.set('unpublishedChanges', true).write()
    return { id }
  }

cuid

Collision-resistant ids optimized for horizontal scaling and performance. For node and browsers.

MIT
Latest version published 2 years ago

Package Health Score

61 / 100
Full package analysis