
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A modern JavaScript library for programmatic molecular construction and SMILES manipulation
Build complex molecules programmatically with an intuitive, composable API. Parse, manipulate, and generate SMILES notation with full round-trip fidelity.
.repeat() and fused acene systems with .fusedRepeat().mirror()
Claude link
npm install smiles-js
<script type="module">
import { Fragment, Ring, FusedRing, Linear } from 'https://unpkg.com/smiles-js@latest/src/index.js';
import { benzene, methyl, ethyl, hydroxyl, carboxyl, phenyl, cyclohexane } from 'https://unpkg.com/smiles-js@latest/src/common.js';
window.SMILES = { Fragment, Ring, FusedRing, Linear, benzene, methyl, ethyl, hydroxyl, carboxyl, phenyl, cyclohexane };
// Your code
</script>
import { parse } from 'smiles-js';
// Parse any SMILES string
const aspirin = parse('CC(=O)Oc1ccccc1C(=O)O');
console.log(aspirin.smiles); // CC(=O)Oc1ccccc1C(=O)O
// Parse complex drugs
const atorvastatin = parse('CC(C)c1c(C(=O)Nc2ccccc2)c(c3ccccc3)c(c4ccc(F)cc4)n1CCC(O)CC(O)CC(=O)O');
console.log(atorvastatin.smiles); // Perfect round-trip!
import { Ring, Linear, Molecule } from 'smiles-js';
// Create benzene ring
const benzene = Ring({ atoms: 'c', size: 6 });
console.log(benzene.smiles); // c1ccccc1
// Add methyl group to make toluene
const methyl = Linear(['C']);
const toluene = benzene.attach(1, methyl);
console.log(toluene.smiles); // c1(C)ccccc1
// Create pyridine via substitution
const pyridine = benzene.substitute(5, 'n');
console.log(pyridine.smiles); // c1cccnc1
import { Ring, Linear } from 'smiles-js';
// Polyethylene trimer: repeat ethylene unit 3 times
const ethylene = Linear(['C', 'C']);
const PE = ethylene.repeat(3, 1, 2);
console.log(PE.smiles); // CCCCCC
// Polystyrene dimer: repeat styrene unit with phenyl branch
const styrene = Linear(['C', 'C']).attach(2, Ring({ atoms: 'c', size: 6 }));
const PS = styrene.repeat(2, 1, 2);
console.log(PS.smiles); // CC(c1ccccc1)CC(c2ccccc2)
// Acene series via fused repeat
const benzene = Ring({ atoms: 'c', size: 6 });
const naphthalene = benzene.fusedRepeat(2, 4); // 2 fused rings
const anthracene = benzene.fusedRepeat(3, 4); // 3 fused rings
import { Ring, Linear, Molecule } from 'smiles-js';
// Diethyl ether: mirror C-C-O around oxygen
const ether = Linear(['C', 'C', 'O']).mirror();
console.log(ether.smiles); // CCOCC
// ABA triblock copolymer
const A = Linear(['C', 'C']);
const B = Ring({ atoms: 'c', size: 6 });
const ABA = Molecule([A, B]).mirror();
console.log(ABA.smiles); // CCc1ccccc1CC
import { parse } from 'smiles-js';
const molecule = parse('CCCc1ccccc1');
console.log(molecule.toCode());
Output:
const molecule1 = Linear(['C', 'C', 'C']);
const molecule2 = Ring({ atoms: 'c', size: 6 });
const molecule3 = Molecule([molecule1, molecule2]);
import { isValidRoundTrip, normalize } from 'smiles-js';
// Quick boolean check
if (isValidRoundTrip('c1ccccc1')) {
console.log('Perfect round-trip!');
}
// Automatic normalization
const normalized = normalize('COc1ccc2nc(S(=O)Cc3ncc(C)c(OC)c3C)[nH]c2c1');
See API.md for complete documentation including:
Contributions welcome! Please see our contributing guidelines.
# Install dependencies
npm install
# Run tests
npm test
# Run linter
npm run lint
MIT License - see LICENSE file for details
FAQs
A JavaScript library for building molecules using composable fragments
We found that smiles-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.