Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/AnonymousUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import ParseUser from './ParseUser';
import type { RequestOptions } from './RESTController';
const uuidv4 = require('uuid/v4');
const uuidv4 = require('./uuid');

let registered = false;

Expand Down
2 changes: 1 addition & 1 deletion src/InstallationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import Storage from './Storage';
const uuidv4 = require('uuid/v4');
const uuidv4 = require('./uuid');

let iidCache = null;

Expand Down
2 changes: 1 addition & 1 deletion src/ParseObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import unsavedChildren from './unsavedChildren';
import type { AttributeMap, OpsMap } from './ObjectStateMutations';
import type { RequestOptions, FullOptions } from './RESTController';

const uuidv4 = require('uuid/v4');
const uuidv4 = require('./uuid');

export type Pointer = {
__type: string,
Expand Down
2 changes: 1 addition & 1 deletion src/RESTController.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @flow
*/
/* global XMLHttpRequest, XDomainRequest */
const uuidv4 = require('uuid/v4');
const uuidv4 = require('./uuid');

import CoreManager from './CoreManager';
import ParseError from './ParseError';
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/InstallationController-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jest.dontMock('../CoreManager');
jest.dontMock('../InstallationController');
jest.dontMock('../Storage');
jest.dontMock('../StorageController.default');
jest.mock('uuid/v4', () => {
jest.mock('../uuid', () => {
let value = 0;
return () => value++ + '';
});
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/ParseObject-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jest.dontMock('../unsavedChildren');
jest.dontMock('../ParseACL');
jest.dontMock('../LocalDatastore');

jest.mock('uuid/v4', () => {
jest.mock('../uuid', () => {
let value = 0;
return () => value++;
});
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/ParseQuery-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jest.dontMock('../LocalDatastore');
jest.dontMock('../OfflineQuery');
jest.dontMock('../LiveQuerySubscription');

jest.mock('uuid/v4', () => {
jest.mock('../uuid', () => {
let value = 0;
return () => value++;
});
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/ParseUser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jest.dontMock('../UniqueInstanceStateController');
jest.dontMock('crypto-js/aes');
jest.dontMock('crypto-js/enc-utf8');

jest.mock('uuid/v4', () => {
jest.mock('../uuid', () => {
let value = 0;
return () => value++;
});
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/RESTController-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

jest.autoMockOff();
jest.useFakeTimers();
jest.mock('uuid/v4', () => {
jest.mock('../uuid', () => {
let value = 1000;
return () => (value++).toString();
});
Expand Down
22 changes: 22 additions & 0 deletions src/uuid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
let uuid = null;

if (process.env.PARSE_BUILD === 'weapp') {
uuid = function () {
const s = [];
const hexDigits = '0123456789abcdef';

for (let i = 0; i < 36; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}

s[14] = '4'; // bits 12-15 of the time_hi_and_version field to 0010
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
s[8] = s[13] = s[18] = s[23] = '-';

return s.join('');
};
} else {
uuid = require('uuid/v4');
}

module.exports = uuid;