Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/js/materialMixin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export declare function materialMixin<T extends Base = Base>(item: T): {
/**
* High-level access to unique elements from material instead of basis.
*/
readonly uniqueElements: string[];
readonly uniqueElements: ("H" | "He" | "Li" | "Be" | "B" | "C" | "N" | "O" | "F" | "Ne" | "Na" | "Mg" | "Al" | "Si" | "P" | "S" | "Cl" | "Ar" | "K" | "Ca" | "Sc" | "Ti" | "V" | "Cr" | "Mn" | "Fe" | "Co" | "Ni" | "Cu" | "Zn" | "Ga" | "Ge" | "As" | "Se" | "Br" | "Kr" | "Rb" | "Sr" | "Y" | "Zr" | "Nb" | "Mo" | "Tc" | "Ru" | "Rh" | "Pd" | "Ag" | "Cd" | "In" | "Sn" | "Sb" | "Te" | "I" | "Xe" | "Cs" | "Ba" | "La" | "Ce" | "Pr" | "Nd" | "Pm" | "Sm" | "Eu" | "Gd" | "Tb" | "Dy" | "Ho" | "Er" | "Tm" | "Yb" | "Lu" | "Hf" | "Ta" | "W" | "Re" | "Os" | "Ir" | "Pt" | "Au" | "Hg" | "Tl" | "Pb" | "Bi" | "Po" | "At" | "Rn" | "Fr" | "Ra" | "Ac" | "Th" | "Pa" | "U" | "Np" | "Pu" | "Am" | "Cm" | "Bk" | "Cf" | "Es" | "Fm" | "Md" | "No" | "Lr" | "Rf" | "Db" | "Sg" | "Bh" | "Hs" | "Mt" | "Ds" | "Rg" | "Cn" | "Nh" | "Fl" | "Mc" | "Lv" | "Ts" | "Og" | "X" | "Vac")[];
lattice: LatticeSchema;
readonly Lattice: Lattice;
/**
Expand Down
3 changes: 2 additions & 1 deletion dist/js/materialMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ function materialMixin(item) {
};
},
get name() {
return item.prop("name", "") || this.formula;
var _a;
return (_a = item.prop("name")) !== null && _a !== void 0 ? _a : this.formula; // if name is not set, use formula, but keep empty string
},
set name(name) {
item.setProp("name", name);
Expand Down
2 changes: 1 addition & 1 deletion dist/js/parsers/xyz_combinatorial_basis.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const math_1 = __importDefault(require("../math"));
// eslint-disable-next-line max-len
const LINE_REGEX = /^([A-Z][a-z]?\/?,?)+\s+(-?\d+\.?\d*|\.\d+)\s+(-?\d+\.?\d*|\.\d+)\s+(-?\d+\.?\d*|\.\d+)\s*$/gi;
// vacancy characters will be used to create vacancies on basis generation
const VACANCY_CHARACTER = "VAC";
const VACANCY_CHARACTER = "Vac";
const COMBINATION_DELIMITER = ",";
const PERMUTATION_DELIMITER = "/";
/**
Expand Down
419 changes: 111 additions & 308 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"prepare": "husky install",
"prettier": "prettier --check src/js tests/js",
"test": "nyc --reporter=text mocha --recursive --bail tests/js/**/*.ts",
"generate-mixins": "ts-node scripts/generate-mixins.ts",
"transpile": "tsc -p tsconfig-transpile.json"
},
"repository": {
Expand All @@ -33,8 +34,8 @@
"@babel/register": "^7.22.15",
"@babel/runtime-corejs3": "^7.16.8",
"@exabyte-io/eslint-config": "2025.5.13-0",
"@mat3ra/code": "2025.7.15-0",
"@mat3ra/esse": "2025.5.16-0",
"@mat3ra/code": "2025.10.8-0",
"@mat3ra/esse": "2025.10.8-0",
"@mat3ra/tsconfig": "2024.6.3-0",
"@mat3ra/utils": "2025.4.14-0",
"@types/crypto-js": "^4.2.2",
Expand Down
2 changes: 1 addition & 1 deletion src/js/materialMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function materialMixin<T extends Base = Base>(item: T) {
},

get name() {
return item.prop("name", "") || this.formula;
return item.prop("name") ?? this.formula; // if name is not set, use formula, but keep empty string
},

set name(name: string) {
Expand Down
4 changes: 2 additions & 2 deletions src/js/parsers/poscar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ function fromPoscar(fileContent: string): object {
startLine = 8;
}

const elements: AtomicElementValue[] = atomSymbols
const elements = atomSymbols
.map((symbol: string, i: number): string[] => Array(atomCounts[i]).fill(symbol))
.reduce((a, b) => a.concat(b), []);
.reduce((a, b) => a.concat(b), []) as AtomicElementValue[];

// Atom coordinates and constraints
const coordinates: AtomicCoordinateValue[] = [];
Expand Down
4 changes: 2 additions & 2 deletions src/js/parsers/xyz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export interface ParsedObject {
*/
function _parseXYZLineAsWords(line: string): ParsedObject {
const words = s.words(line);
const elementWithOptionalLabel: AtomicElementValue = words[0];
const element: AtomicElementValue = elementWithOptionalLabel.replace(/\d$/, ""); // Fe1 => Fe
const elementWithOptionalLabel = words[0];
const element = elementWithOptionalLabel.replace(/\d$/, "") as AtomicElementValue; // Fe1 => Fe
const generateConstraintValue = (n: number) => parseInt(`${n}`, 10) !== 0;

const basisLineConfig: ParsedObject = {
Expand Down
2 changes: 1 addition & 1 deletion src/js/parsers/xyz_combinatorial_basis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import math from "../math";
const LINE_REGEX =
/^([A-Z][a-z]?\/?,?)+\s+(-?\d+\.?\d*|\.\d+)\s+(-?\d+\.?\d*|\.\d+)\s+(-?\d+\.?\d*|\.\d+)\s*$/gi;
// vacancy characters will be used to create vacancies on basis generation
const VACANCY_CHARACTER = "VAC";
const VACANCY_CHARACTER = "Vac";
const COMBINATION_DELIMITER = ",";
const PERMUTATION_DELIMITER = "/";
/**
Expand Down
Loading