<commit_before>_ = require('lodash')

# TODO: This should be fetch from the server
DEVICES = require('./device-data.json')

exports.getDisplayName = (device) ->
	if _.indexOf(exports.getSupportedDevices(), device) isnt -1
		return device

	for key, value of DEVICES
		if _.indexOf(value.names, device) isnt -1
			return key
	return 'Unknown'

exports.getDeviceSlug = (device) ->
	displayName = exports.getDisplayName(device)
	return DEVICES[displayName]?.slug or 'unknown'

exports.getSupportedDevices = ->
	return _.keys(DEVICES)<commit_msg>Document resin/device<commit_after>_ = require('lodash')

# TODO: This should be fetch from the server
DEVICES = require('./device-data.json')

# Get display name for a device
#
# For a list of supported devices, see getSupportedDevices()
#
# @param {String} device device name
# @return {String} device display name or 'Unknown'
#
# @example Get display name
#		console.log resin.device.getDisplayName('raspberry-pi') # Raspberry Pi
#		console.log resin.device.getDisplayName('rpi') # Raspberry Pi
#
exports.getDisplayName = (device) ->
	if _.indexOf(exports.getSupportedDevices(), device) isnt -1
		return device

	for key, value of DEVICES
		if _.indexOf(value.names, device) isnt -1
			return key
	return 'Unknown'

# Get device slug
#
# @param {String} device device name
# @return {String} device slug or 'unknown'
#
# @example Get device slug
#		console.log resin.device.getDeviceSlug('Raspberry Pi') # raspberry-pi
#
exports.getDeviceSlug = (device) ->
	displayName = exports.getDisplayName(device)
	return DEVICES[displayName]?.slug or 'unknown'

# Get a list of supported devices
#
# @return {Array<String>} a list of all supported devices, by their display names
#
# @example Get all supported devices
#		devices = resin.device.getSupportedDevices()
#		console.log(devices)
#
exports.getSupportedDevices = ->
	return _.keys(DEVICES)
{'fraction_non_alphanumeric': 0.11671087533156499, 'fraction_numerical': 0.002122015915119363, 'mean_word_length': 4.8390092879256965, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6319922', 'n_tokens_mistral': 613, 'n_tokens_neox': 584, 'n_words': 178}