Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
device-sizes
Advanced tools
Collection of various properties relevant for development of various popular mobile devices.
npm install device-sizes
import { deviceSizes } from 'device-sizes'
console.log(deviceSizes.iphone15.name === 'iPhone 15') // true
const widths = Object.keys(deviceSizes).map((key) => deviceSizes[key].width)
const sumOfWidths = widths.reduce((previous, current) => previous + current, 0)
const averageWidth = sumOfWidths / Object.keys(deviceSizes).length
console.log(averageWidth)
interface Device {
id: string
name: string
width: number
height: number
// Screen diagonal in inches
size: number
// In Pixels per Inch (ppi)
density: number
// Responsive scaling factor
scale: number
brand: Brand
camera: Camera
type: Type
}
enum Brand {
Apple,
Samsung,
Google,
Xiaomi,
Oppo,
Huawei,
}
enum Camera {
Notch,
DynamicIsland,
Center,
Left,
Right,
Outside,
Unknown,
}
enum Type {
Phone,
Tablet,
}
The types can be imported from the plugin when needed.
import { Device, Brand, Camera, Type } from 'device-sizes'
To avoid bundling all devices or download unnecessary properties the data can be queried through GraphQL. The API is reachable at https://device-sizes.vercel.app/api
.
import { ApolloClient, InMemoryCache, gql, HttpLink } from '@apollo/client'
const client = new ApolloClient({
uri: 'https://device-sizes.vercel.app/api'
cache: new InMemoryCache(),
})
const response = await client.query({
query: gql`
query GetDevices {
devices {
id
name
width
height
}
}
`,
})
const { devices } = response.data
FAQs
Collection of properties of popular mobile devices.
We found that device-sizes demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.