{"id":22208543,"url":"https://github.com/nicorobo/mendeleev","last_synced_at":"2025-07-27T09:30:42.313Z","repository":{"id":57294568,"uuid":"51568175","full_name":"nicorobo/Mendeleev","owner":"nicorobo","description":":microscope: A small library for building compounds and working with element data.","archived":false,"fork":false,"pushed_at":"2017-03-22T17:03:55.000Z","size":530,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-02T01:19:56.330Z","etag":null,"topics":["chemistry","compound","library","parser"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/mendeleev","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nicorobo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-12T05:03:52.000Z","updated_at":"2024-02-08T18:08:46.000Z","dependencies_parsed_at":"2022-08-29T08:01:43.550Z","dependency_job_id":null,"html_url":"https://github.com/nicorobo/Mendeleev","commit_stats":null,"previous_names":["nickroberts404/mendeleev"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicorobo%2FMendeleev","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicorobo%2FMendeleev/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicorobo%2FMendeleev/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicorobo%2FMendeleev/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicorobo","download_url":"https://codeload.github.com/nicorobo/Mendeleev/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227786852,"owners_count":17819787,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chemistry","compound","library","parser"],"created_at":"2024-12-02T19:20:28.474Z","updated_at":"2024-12-02T19:20:29.119Z","avatar_url":"https://github.com/nicorobo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://dl.dropboxusercontent.com/s/m2ohwsvmfknup74/mendeleev-icon.png?dl=0\" alt=\"logo\" width=\"80px\" /\u003e\n\n# Mendeleev\nA small library for working with element data and building compounds.\n\n### PeriodicTable\nPeriodicTable contains information on individual elements.\nIt allows retrieval by symbol, name, or atomic number.\nIt also allows filtering by type, period, and group.\n\n#### Initialization\n```js\nimport { PeriodicTable } from 'mendeleev'; // ES2015\nvar PeriodicTable = require('mendeleev').PeriodicTable; // CommonJS\n```\n\n#### `.getElement(str)`\nTakes an element's symbol as an argument, such as 'H' or 'Ni', returning the elements data if it's found, null if it's not.\n```js\nvar hydrogen = PeriodicTable.getElement('H');\nhydrogen == {  \n    name:\"hydrogen\",\n    symbol:\"H\",\n    type:\"other-nonmetal\",\n    number:1,\n    mass:1.008,\n    period:1,\n    group:1,\n    melting:14.01,\n    boiling:20.28,\n    density:0.00008988,\n    electronegativity:2.20,\n    radius:25,\n    valence:1,\n    specificheat:14.304\n}\n\nvar unknown = PeriodicTable.getElement('Nope');\nunknown == null;\n```\n#### `.getAtomic(number)`\nTakes an element's atomic number as an argument, such as 17 or 118, returning the elements data if it's found, null if it's not.\n```js\nvar helium = PeriodicTable.getAtomic(2); // { name: 'helium', ... }\nvar unknown = PeriodicTable.getAtomic(1028); // null\n```\n\n#### `.getType(string)`\nTakes an element type as an argument, returning an array of matching elements.\nPossible element types include: `alkali-metal`, `alkaline-earth`, `transition-metal`, `post-transition-metal`, `metalloid`, `other-nonmetal`, `halogen`, `noble-gas`, `lanthanoid`, `actinoid`. \n```js\nvar halogens = PeriodicTable.getType('halogen'); // [{ name: 'fluorine', ... }, { name: 'chlorine', ... }, ...]\nvar unknown = PeriodicTable.getType('fake-type'); // []\n```\n\n#### `.getPeriod(number)`\nTakes an elemental period (1 to 7) as an argument, returning an array of matching elements.\n```js\nvar periodOne = PeriodicTable.getPeriod(1); // [{ name: 'hydrogen', ... }, { name: 'helium', ... }, ...]\nvar unknown = PeriodicTable.getPeriod(1000); // []\n```\n\n#### `.getGroup(number)`\nTakes an elemental group (1 to 18) as an argument, returning an array of matching elements.\n```js\nvar alkalineEarth = PeriodicTable.getGroup(2); // [{ name: 'beryllium', ... }, { name: 'magnesium', ... }, ...]\nvar unknown = PeriodicTable.getGroup(1000); // []\n```\n\n### Compound\nCompound is an object that represents a chemical compound.\nAfter being initialized, it can have elements added and subtracted.\nIt also has methods for getting the molecular mass, mass percentages, and for creating an HTML representation of the compound.\n\n#### Initialization\nYou can initialize an empty compound, or pre-populate it with elements.\n```js\nimport { Compound } from 'mendeleev'; // ES2015\nvar Compound = require('mendeleev').Compound; // CommonJS\n\nvar empty = new Compound();\nvar water = new Compound({'H': 2, 'O', 1});\n```\n\n#### `.add(str, ?number)`\nAllows you to add an element to a compound, with an optional quantity. The default quantity is 1.\n```js\nvar water = new Compound();\nwater.add('H', 2);\nwater.add('O');\n```\n\n#### `.remove(str, ?number)`\nAllows you to remove an element from a compound, with an optional quantity. The default quantity is 1.\n```js\nvar c = new Compound({'H': 2, 'O': 1});\nc.remove('O') // Compound would be H2\n```\n\n#### `.getMass()`\nReturns the molecular mass of the compound.\n```js\nvar silverNitrate = new Compound({\"Ag\": 1, \"N\": 1, \"O\": 3})\nvar m = silverNitrate.getMass(); // 169.87490\n```\n\n#### `.getPercentages()`\nReturns an array in the form of `[{element: \u003cstr\u003e, percentage: \u003cnumber\u003e}, ....]`\n```js\nvar water = new Compound({'H': 2, 'O', 1});\nvar p = water.getPercentages(); // [{element: 'H', percentage:11.19}, {element: 'O', percentage:88.81}]\n```\n\n#### `.toHTML()`\nReturns the compound as HTML, giving the quantities `\u003csub\u003e` tags.\n```js\nvar water = new Compound({'H': 2, 'O', 1});\nvar h = water.toHTML(); // H\u003csub\u003e2\u003c/sub\u003eO\n```\n\n### Utility\nUtility is where a few static utility methods are kept. It currently only has one.\n\n#### Initialization\n```js\nimport { Utility } from 'mendeleev'; // ES2015\nvar Utility = require('mendeleev').Utility; // CommonJS\n```\n\n#### `.stringToElementList(string)`\nAccepts a string, such as 'H2O', and turns it into an element list, of the form {'H': 2, 'O', 1}. An element list is what you would use to initialize a compound. \n*This currently does not work with parentheses*\n```js\nvar formula = \"AlO\";\nvar elementList = Utility.stringToElementList(formula);\nvar aluminiumMonoxide = new Compound(elementList);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicorobo%2Fmendeleev","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicorobo%2Fmendeleev","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicorobo%2Fmendeleev/lists"}