mirror of
https://github.com/github/codeql-action.git
synced 2025-12-27 01:30:10 +08:00
43 lines
547 B
JavaScript
43 lines
547 B
JavaScript
'use strict';
|
|
const clone = require('lodash/clone');
|
|
|
|
class ContextRef {
|
|
constructor() {
|
|
this.value = {};
|
|
}
|
|
|
|
get() {
|
|
return this.value;
|
|
}
|
|
|
|
set(newValue) {
|
|
this.value = newValue;
|
|
}
|
|
|
|
copy() {
|
|
return new LateBinding(this);
|
|
}
|
|
}
|
|
module.exports = ContextRef;
|
|
|
|
class LateBinding extends ContextRef {
|
|
constructor(ref) {
|
|
super();
|
|
this.ref = ref;
|
|
this.bound = false;
|
|
}
|
|
|
|
get() {
|
|
if (!this.bound) {
|
|
this.set(clone(this.ref.get()));
|
|
}
|
|
|
|
return super.get();
|
|
}
|
|
|
|
set(newValue) {
|
|
this.bound = true;
|
|
super.set(newValue);
|
|
}
|
|
}
|