Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

atom-sorter

Package Overview
Dependencies
Maintainers
6
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atom-sorter - npm Package Compare versions

Comparing version 0.8.0 to 0.9.1

4

package.json
{
"name": "atom-sorter",
"version": "0.8.0",
"version": "0.9.1",
"description": "Callback allowing to sort chemical elements (atoms) in Hill order",

@@ -21,4 +21,4 @@ "main": "src/index.js",

"dependencies": {
"mf-utilities": "^0.8.0"
"mf-utilities": "^0.9.1"
}
}

@@ -6,7 +6,7 @@ 'use strict';

test('atom-sorter test', () => {
expect(atomSorter('C', 'C')).toBe(0);
expect(atomSorter('C', 'H')).toBe(-1);
expect(atomSorter('C', 'O')).toBe(-1);
expect(atomSorter('N', 'O')).toBe(-1);
expect(atomSorter('Cl', 'Br')).toBe(1);
expect(atomSorter('C', 'C')).toBe(0);
expect(atomSorter('C', 'H')).toBe(-1);
expect(atomSorter('C', 'O')).toBe(-1);
expect(atomSorter('N', 'O')).toBe(-1);
expect(atomSorter('Cl', 'Br')).toBe(1);
});

@@ -16,11 +16,11 @@

test('sort an array', () => {
let atoms = ['H', 'Cl', 'C', 'O', 'N', 'Br'];
atoms.sort((a, b) => atomSorter(a, b));
expect(atoms).toEqual(['C', 'H', 'Br', 'Cl', 'N', 'O']);
let atoms = ['H', 'Cl', 'C', 'O', 'N', 'Br'];
atoms.sort((a, b) => atomSorter(a, b));
expect(atoms).toStrictEqual(['C', 'H', 'Br', 'Cl', 'N', 'O']);
});
test('sort an array HCl', () => {
let atoms = ['Cl', 'H'];
atoms.sort((a, b) => atomSorter(a, b));
expect(atoms).toEqual(['H', 'Cl']);
let atoms = ['Cl', 'H'];
atoms.sort((a, b) => atomSorter(a, b));
expect(atoms).toStrictEqual(['H', 'Cl']);
});
'use strict';
function atomSorter(a, b) {
if (a === b) return 0;
if (a === 'C') return -1;
if (b === 'C') return 1;
if (a === 'H') return -1;
if (b === 'H') return 1;
if (a < b) return -1;
return 1;
if (a === b) return 0;
if (a === 'C') return -1;
if (b === 'C') return 1;
if (a === 'H') return -1;
if (b === 'H') return 1;
if (a < b) return -1;
return 1;
}
module.exports = atomSorter;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc