UNPKG

android-model-names

Version:

Convert Android device strings to human-readable manufacturer and model names

46 lines (41 loc) 1.32 kB
// android-device-names // Version 1.0.3 // https://github.com/google-fabric/android-model-names // (c) 2017 Google Inc. // android-device-names may be freely distributed under the MIT license. ;(function () { var fullDeviceMap = require('./android-model-map.json'); var fullManufacturerMap = require('./android-manufacturer-map.json'); function getAndroidModelName(str, opts) { if (!str || typeof str !== 'string') return; opts = typeof opts === 'undefined' ? {} : opts; if (opts.isManufacturer) { return fullManufacturerMap[str] || str; } else { // Perform lookup. (Value is a tuple of [model,manufacturer]) var match = fullDeviceMap[str]; // Post-processing. if (opts.full) { return match ? { manufacturer: match[1], model: match[0], key: str } : { key: str }; } else { return match ? match[0] : str; } } }; if (typeof define === 'function' && define.amd) { // RequireJS / AMD define(function () { return getAndroidModelName; }); } else if (typeof module !== 'undefined' && module.exports) { // CommonJS module.exports = getAndroidModelName; } else { // Global this.getAndroidModelName = getAndroidModelName; } }.call(this));