How to use uuidv4 - 10 common examples

To help you get started, we’ve selected a few uuidv4 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 accordproject / template-studio-v2 / src / sagas / contractSaga.js View on Github external
nodes.splice((currentPosition + 1), 0, clauseNodeJSON, paragraphSpaceNodeJSON);
    const realNewMd = slateTransformer.toMarkdown(Value.fromJSON(newSlateValueAsJSON));

    // update contract on store with new slate and md values
    yield put(actions.documentEdited(Value.fromJSON(newSlateValueAsJSON), realNewMd));
    const grammar = templateObj.parserManager.getTemplatizedGrammar();


    // Temporary roundtrip and rebuild grammar
    const grammarRound = roundTrip(grammar);
    templateObj.parserManager.buildGrammar(grammarRound);

    const sampleText = templateObj.getMetadata().getSamples().default;
    const model = templateObj.getModelManager().getModels();
    const logic = templateObj.getScriptManager().getLogic();
    const clauseTemplateId = uuidv4(); // unique identifier for a clause template

    // add a new clause template to the store so user can edit template
    yield put(clauseTemplatesActions.addClauseTemplate({
      metadata, model, logic, sampleText, grammar, id: clauseTemplateId, clauseId
    }));

    // add instatiated clause to list of clauses in the contract state
    yield put(actions.addToContractSuccess(clauseId, clauseTemplateId));
  } catch (err) {
    console.error(err);
    yield put(appActions.addAppError('Failed to add clause to contract', err));
  }
}
github accordproject / template-studio-v2 / src / sagas / contractSaga.js View on Github external
uri: clauseTemplateRef
    };
    // get the templateObj from the store if we already have it or load if not
    const templateObj = yield call(addTemplateObjectToStore, actionRedesign);

    const metadata = templateObj.getMetadata();
    const grammar = templateObj.parserManager.getTemplatizedGrammar();

    // Temporary roundtrip and rebuild grammar
    const grammarRound = roundTrip(grammar);
    templateObj.parserManager.buildGrammar(grammarRound);

    const sampleText = templateObj.getMetadata().getSamples().default;
    const model = templateObj.getModelManager().getModels();
    const logic = templateObj.getScriptManager().getLogic();
    const clauseTemplateId = uuidv4(); // unique identifier for a clause template

    // add a new clause template to the store so user can edit template
    yield put(clauseTemplatesActions.addClauseTemplate({
      metadata, model, logic, sampleText, grammar, id: clauseTemplateId, clauseId
    }));

    // add instatiated clause to list of clauses in the contract state
    yield put(actions.pasteToContractSuccess(clauseId, clauseTemplateId));
  } catch (err) {
    yield put(appActions.addAppError('Failed to add clause to contract', err));
  }
}
github accordproject / template-studio-v2 / src / sagas / contractSaga.js View on Github external
export function* addToContract(action) {
  try {
    // get the templateObj from the store if we already have it
    // or load it and add it to the store if we do not
    const templateObj = yield call(addTemplateObjectToStore, action);

    const slateValue = yield select(contractSelectors.slateValue);
    const metadata = templateObj.getMetadata();

    // get the user's current position in Slate dom to insert clause at
    const currentPosition = slateValue.selection.anchor.path.get(0);
    const clauseId = uuidv4(); // unique identifier for a clause instance
    const clauseMd = `\`\`\` 
  ${metadata.getSample()}
  \`\`\``;

    // Create a new paragraph in JSON for spacing between clauses
    const paragraphSpaceNodeJSON = {
      object: 'block',
      type: 'paragraph',
      data: {
      },
      nodes: [
        {
          object: 'text',
          text: '',
          marks: []
        }
github zilpay / zil-pay / tests / unit / lib / stream / message / tabs-message.spec.js View on Github external
it('test init class TabsMessage', () => {
    const msg = {
      type: uuid(),
      payload: {
        random: uuid()
      }
    }
    const message = new TabsMessage(msg)

    expect(message).toBeTruthy()
    expect(message.send).toBeTruthy()
    expect(message.type).toEqual(msg.type)
    expect(message.payload).toEqual(msg.payload)
  })
github zilpay / zil-pay / tests / unit / lib / stream / message / secure-message.spec.js View on Github external
it('test init class SecureMessage', () => {
    const msg = {
      type: uuid(),
      payload: {
        random: uuid()
      }
    }
    const message = new SecureMessage(msg)

    expect(message).toBeTruthy()
    expect(message.send).toBeTruthy()
    expect(message.type).toEqual(msg.type)
    expect(message.payload).toEqual(msg.payload)
  })
github zilpay / zil-pay / tests / unit / components / input.spec.js View on Github external
* Modified By: the developer formerly known as Rinat(lich666dead) at 
 * -----
 * Copyright (c) 2019 ZilPay
 */
import { shallowMount, createLocalVue } from '@vue/test-utils'
import vueBemCn from 'vue-bem-cn'
import Input, { INPUT_TYPES } from 'src/components/Input.vue'
import { uuid } from 'uuidv4'
import {
  BEM_CONFIG,
  SIZE_VARIANS
} from 'src/config'

const localVue = createLocalVue()
const TEST_TITLE = uuid()
const TEST_ERROR = uuid()
const TEST_VALUE = uuid()
const TEST_PLACEHOLDER = uuid()

localVue.use(vueBemCn, { delimiters: BEM_CONFIG })

describe('components:Input', () => {
  const wrapper = shallowMount(Input, {
    localVue,
    propsData: {
      size: SIZE_VARIANS.md,
      disabled: false,
      round: true,
      block: true,
      type: INPUT_TYPES.number,
      min: 10,
      max: 20,
github zilpay / zil-pay / tests / unit / components / input.spec.js View on Github external
* -----
 * Copyright (c) 2019 ZilPay
 */
import { shallowMount, createLocalVue } from '@vue/test-utils'
import vueBemCn from 'vue-bem-cn'
import Input, { INPUT_TYPES } from 'src/components/Input.vue'
import { uuid } from 'uuidv4'
import {
  BEM_CONFIG,
  SIZE_VARIANS
} from 'src/config'

const localVue = createLocalVue()
const TEST_TITLE = uuid()
const TEST_ERROR = uuid()
const TEST_VALUE = uuid()
const TEST_PLACEHOLDER = uuid()

localVue.use(vueBemCn, { delimiters: BEM_CONFIG })

describe('components:Input', () => {
  const wrapper = shallowMount(Input, {
    localVue,
    propsData: {
      size: SIZE_VARIANS.md,
      disabled: false,
      round: true,
      block: true,
      type: INPUT_TYPES.number,
      min: 10,
      max: 20,
      step: 1,
github zilpay / zil-pay / tests / unit / components / input.spec.js View on Github external
* -----
 * Modified By: the developer formerly known as Rinat(lich666dead) at 
 * -----
 * Copyright (c) 2019 ZilPay
 */
import { shallowMount, createLocalVue } from '@vue/test-utils'
import vueBemCn from 'vue-bem-cn'
import Input, { INPUT_TYPES } from 'src/components/Input.vue'
import { uuid } from 'uuidv4'
import {
  BEM_CONFIG,
  SIZE_VARIANS
} from 'src/config'

const localVue = createLocalVue()
const TEST_TITLE = uuid()
const TEST_ERROR = uuid()
const TEST_VALUE = uuid()
const TEST_PLACEHOLDER = uuid()

localVue.use(vueBemCn, { delimiters: BEM_CONFIG })

describe('components:Input', () => {
  const wrapper = shallowMount(Input, {
    localVue,
    propsData: {
      size: SIZE_VARIANS.md,
      disabled: false,
      round: true,
      block: true,
      type: INPUT_TYPES.number,
      min: 10,
github zilpay / zil-pay / tests / unit / components / button.spec.js View on Github external
* -----
 * Modified By: the developer formerly known as Rinat(lich666dead) at 
 * -----
 * Copyright (c) 2019 ZilPay
 */
import { shallowMount, createLocalVue } from '@vue/test-utils'
import vueBemCn from 'vue-bem-cn'
import Button from 'src/components/Button.vue'
import {
  BEM_CONFIG,
  SIZE_VARIANS,
  COLOR_VARIANTS
} from 'src/config'
import { uuid } from 'uuidv4'

const TEST_TEXT = uuid()
const localVue = createLocalVue()

localVue.use(vueBemCn, { delimiters: BEM_CONFIG })

describe('components:Button', () => {
  const wrapper = shallowMount(Button, {
    localVue,
    propsData: {
      size: SIZE_VARIANS.md,
      color: COLOR_VARIANTS.info,
      disabled: false,
      round: true,
      block: true
    },
    slots: {
      default: [TEST_TEXT]
github zilpay / zil-pay / tests / unit / components / bottom-bar.spec.js View on Github external
COLOR_VARIANTS,
  SIZE_VARIANS,
  BEM_CONFIG
} from 'src/config'

const localVue = createLocalVue()

const TEST = [
  {
    value: 'Send',
    event: 'send',
    icon: ICON_VARIANTS.add,
    iconType: ICON_TYPE.svg,
    variant: COLOR_VARIANTS.primary,
    size: SIZE_VARIANS.sm,
    uuid: uuid()
  },
  {
    value: 'Receive',
    event: 'receive',
    icon: ICON_VARIANTS.add,
    iconType: ICON_TYPE.svg,
    variant: COLOR_VARIANTS.primary,
    size: SIZE_VARIANS.sm,
    uuid: uuid()
  }
]

localVue.use(vueBemCn, { delimiters: BEM_CONFIG })

describe('components:BottomBar', () => {
  const wrapper = shallowMount(BottomBar, {

uuidv4

uuidv4 creates v4 UUIDs.

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis