Skip to content

Commit

Permalink
Deprecate createLocation and locationsAreEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
mjackson committed Sep 6, 2019
1 parent 773751c commit 2c7250b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 15 deletions.
20 changes: 10 additions & 10 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"esm/history.js": {
"bundled": 28076,
"minified": 12353,
"gzipped": 3575,
"bundled": 29006,
"minified": 13074,
"gzipped": 3778,
"treeshaked": {
"rollup": {
"code": 208,
"import_statements": 132
},
"webpack": {
"code": 1324
"code": 2207
}
}
},
"umd/history.js": {
"bundled": 33021,
"minified": 11943,
"gzipped": 3917
"bundled": 33889,
"minified": 12474,
"gzipped": 4193
},
"umd/history.min.js": {
"bundled": 30384,
"minified": 9993,
"gzipped": 3501
"bundled": 31154,
"minified": 10143,
"gzipped": 3541
}
}
10 changes: 10 additions & 0 deletions modules/deprecate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import warning from './warning.js';

export default function deprecate(fn, message) {
let alreadyWarned = false;
return function() {
warning(alreadyWarned, message);
alreadyWarned = true;
return fn.apply(this, arguments);
};
}
29 changes: 24 additions & 5 deletions modules/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
export { default as createBrowserHistory } from './createBrowserHistory';
export { default as createHashHistory } from './createHashHistory';
export { default as createMemoryHistory } from './createMemoryHistory';
export { createLocation, locationsAreEqual } from './LocationUtils';
export { parsePath, createPath } from './PathUtils';
export { default as createBrowserHistory } from './createBrowserHistory.js';
export { default as createHashHistory } from './createHashHistory.js';
export { default as createMemoryHistory } from './createMemoryHistory.js';
export { parsePath, createPath } from './PathUtils.js';

import deprecate from './deprecate.js';
import { createLocation, locationsAreEqual } from './LocationUtils.js';

const deprecatedCreateLocation = deprecate(
createLocation,
'createLocation is deprecated and will be removed in the next major release.' +
' To create a location object from a URL string, use `location = parsePath(url)` instead.'
);

const deprecatedLocationsAreEqual = deprecate(
locationsAreEqual,
'locationsAreEqual is deprecated and will be removed in the next major release.' +
' To check if two location objects represent the same location, compare `locationA.key === locationB.key` instead.'
);

export {
deprecatedCreateLocation as createLocation,
deprecatedLocationsAreEqual as locationsAreEqual
};

0 comments on commit 2c7250b

Please sign in to comment.