-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
620152a
commit 6f8555f
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (C) 2024 brittni and the polar bear LLC. | ||
* | ||
* This file is a part of brittni and the polar bear's Generative Art Library, | ||
* which is released under the GNU Affero General Public License, Version 3.0. | ||
* You may not use this file except in compliance with the license. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. See LICENSE or go to | ||
* https://www.gnu.org/licenses/agpl-3.0.en.html for full license details. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Affero General Public License for more details. | ||
*/ | ||
|
||
import {PaletteColor} from 'palette'; | ||
|
||
import {Discriminators} from './discriminators'; | ||
|
||
/** | ||
* Methods for evaluating if objects implement various interfaces. | ||
* | ||
* @category Discriminator | ||
*/ | ||
export class Discriminator { | ||
/** | ||
* Determines if the given object is a {@link PaletteColor} | ||
* (i.e. implements the PaletteColor interface). | ||
* | ||
* @param object | ||
* | ||
* @returns `true` if the given object implements | ||
* the {@link PaletteColor} interface, `false` if it does not. | ||
*/ | ||
public static isPaletteColor(object: any): object is PaletteColor { | ||
let hasMatch: boolean = false; | ||
|
||
if (object) { | ||
hasMatch = object.DISCRIMINATOR === Discriminators.PALETTE_COLOR; | ||
} | ||
|
||
return hasMatch; | ||
} | ||
} |