10 examples of 'history.push' in JavaScript

Every line of 'history.push' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
48export function pushHistoryPath(history, path, search) {
49 pushOrUpdateHistory(history, false, null, null, path, search);
50}
Important

Use secure code every time

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

76push(state) {
77 const newHistory = this.merge({
78 undos: this.undos.push(snapshot(state, this.merged)),
79 redos: new Stack(),
80 merged: 1
81 });
82
83 return newHistory.prune();
84}
60private pop(deque: Deque<TextEdit>) : TextEdit {
61 return deque.empty() ? null : deque.pop_back();
62}
177private insertIntoHistory(c: CommandInformation) {
178 const preservedHistory =
179 this.history.length === this.MAX_HISTORY
180 ? this.history.slice(1)
181 : this.history;
182 this.history = [...preservedHistory, c];
183}
83updateHistory() {
84 if (count >= 18) {
85 colors.shift()
86 }
87 this.$items.forEach((v, i) => {
88 setStyle('background', colors[colors.length - 1 - i], v)
89 if (i < count) {
90 addClass(this.classes.HISTORYITEMEMPTY, v)
91 }
92 })
93}
28push(params = {}) {
29 return NavigationSpecific.push(this, params);
30}
47push(ev) {
48 this.undo_history.push(ev);
49}
20push (action) {
21 this.delta.push(action)
22 return delay(() => this.concat())
23}
65function forward(steps = 1) {
66 if (canGoForward(steps)) {
67 currentPosition += steps;
68 } else {
69 currentPosition = historyData.length - 1;
70 }
71
72 process.nextTick(notifyListeners);
73 return current();
74}
25push(path: string | LocationDescriptorObject, state?: any) {
26 // Do not navigate if the path object matches
27 const nextPath = typeof path === 'string' ? path : createPath(path);
28 if (nextPath === createPath(this.history.location)) return;
29
30 if (Date.now() - this.lastPush > this.wait) {
31 // TypeScript doesn't recognize our push as a proxy for History.push's
32 // overloaded signature, and it's really hard to fix this properly
33 this.history.push(path as string, state);
34 } else {
35 try {
36 this.history.replace(path as string, state);
37 } catch (e) {
38 // Ignore Safari's history.replaceState() rate limit error.
39 // See https://github.com/nusmodifications/nusmods/issues/763
40 if (
41 e.name === 'SecurityError' &&
42 e.message.includes('Attempt to use history.replaceState()')
43 ) {
44 return;
45 }
46
47 // Continue throwing all other errors
48 throw e;
49 }
50 }
51
52 this.lastPush = Date.now();
53}

Related snippets