-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathmixin.ts
56 lines (47 loc) · 1.51 KB
/
mixin.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2021 Google LLC. Use of this source code is governed by an
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
import {hash} from 'immutable';
import {Value} from './index';
/** A first-class SassScript mixin. */
export class SassMixin extends Value {
/**
* This is the unique ID that the compiler uses to determine which mixin it
* refers to.
*
* This is marked as public so that the protofier can access it, but it's not
* part of the package's public API and should not be accessed by user code.
* It may be renamed or removed without warning in the future.
*/
readonly id: number;
/**
* This is the unique context that the host uses to determine which
* compilation this mixin belongs to.
*
* This is marked as public so that the protofier can access it, but it's not
* part of the package's public API and should not be accessed by user code.
* It may be renamed or removed without warning in the future.
*/
readonly compileContext: symbol;
constructor(id: number, compileContext: symbol) {
super();
this.id = id;
this.compileContext = compileContext;
}
equals(other: Value): boolean {
return (
other instanceof SassMixin &&
other.compileContext === this.compileContext &&
other.id === this.id
);
}
hashCode(): number {
return hash(this.id);
}
toString(): string {
return `<compiler mixin ${this.id}>`;
}
assertMixin(): SassMixin {
return this;
}
}