How to use the uuidv4 function in uuidv4

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 SelfDevTV / trello-clone / src / reducers / boardOrderReducer.js View on Github external
import { CONSTANTS } from "../actions";
import uuid from "uuidv4";

console.log(uuid());

const initialState = ["board-0"];

const boardOrderReducer = (state = initialState, action) => {
  switch (action.type) {
    case CONSTANTS.ADD_BOARD: {
      return [...state, `board-${action.payload.id}`];
    }
    default:
      return state;
  }
};

export default boardOrderReducer;
github diescake / igata / src / app / reducers / todo.ts View on Github external
export const todoReducer: Reducer = (state: TodoState = defaultState, action: TodoAction): TodoState => {
  switch (action.type) {
    case Type.ADD_TODO: {
      if (state.fetching) {
        return state
      }

      const newTodo = {
        id: uuid(),
        done: false,
        text: action.payload.text,
      }

      return { ...state, todos: [...state.todos, newTodo] }
    }

    case Type.UPDATE_TODO: {
      if (state.fetching) {
        return state
      }

      const index = state.todos.findIndex((todo: Todo) => todo.id === action.payload.id)
      if (index === -1) {
        return state
      }
github SelfDevTV / trello-clone / src / actions / cardsActions.js View on Github external
export const addCard = (listID, text) => {
  const id = uuid();
  return {
    type: CONSTANTS.ADD_CARD,
    payload: { text, listID, id }
  };
};
github SelfDevTV / trello-clone / src / actions / boardActions.js View on Github external
export const addBoard = title => {
  const id = uuid();
  return {
    type: CONSTANTS.ADD_BOARD,
    payload: { title, id }
  };
};
github SelfDevTV / trello-clone / src / actions / listsActions.js View on Github external
return (dispatch, getState) => {
    const boardID = getState().activeBoard;
    const id = uuid();
    dispatch({
      type: CONSTANTS.ADD_LIST,
      payload: { title, boardID, id }
    });
  };
};

uuidv4

uuidv4 creates v4 UUIDs.

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis