UNPKG

atom-nuclide

Version:

A unified developer experience for web and mobile development, built as a suite of features on top of Atom to provide hackability and the support of an active community.

39 lines (32 loc) 1.03 kB
/* * Copyright (c) 2015-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the license found in the LICENSE file in * the root directory of this source tree. */ function capitalize(word) { if (word.length === 0) { return word; } return word.charAt(0).toUpperCase() + word.slice(1); } /** * This is pulled out into its own function rather than using localeCompare * directly in case we every choose another sorting algorithm. Such as some * sort of natural compare algorithm. */ function compareStrings(one_, two_) { var one = one_; var two = two_; one = (one || '').toLowerCase(); two = (two || '').toLowerCase(); return one.localeCompare(two); } function isCapitalized(name) { return name.length > 0 && name.charAt(0).toUpperCase() === name.charAt(0); } function isLowerCase(name) { return name.toLowerCase() === name; } module.exports = { capitalize: capitalize, compareStrings: compareStrings, isCapitalized: isCapitalized, isLowerCase: isLowerCase };