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

srcset-parse

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

srcset-parse

Extra tiny parser of srcset definitions

  • 1.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
799
decreased by-14.64%
Maintainers
1
Weekly downloads
 
Created
Source

srcset-parse

An extra small srcset attribute parser compliant with the latest spec. Unlike srcset package, supports:

  • URLs that contain commas;
  • Zero or one descriptors per image definitions (like 2x or 100w, but not both!).

Example usage:

import parse from "srcset-parse";

/**
 * [
 *   { url: "hifi-cat.jpeg",  density: 3 },
 *   { url: "lowfi-cat.jpeg", width: 128 },
 * ]
 */
parse("hifi-cat.jpeg 3x, lowfi-cat.jpeg 128w");

Using with TypeScript

The library is written in TypeScript, so you can import types if needed:

import parse, { ImageCandidate } from "srcset-parse";

const result: ImageCandidate[] = parse("icon@2x.png 2x, icon.png 1x");

Platform support

This library is written according to the ES2015 standard. Make sure your platform supports it, or your project is configured to transpile external modules.

FAQs

Package last updated on 13 Jul 2020

Did you know?

Socket

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.

Install

Related posts

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