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

asset-resolver

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asset-resolver

Find an asset in a set of locations

  • 3.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

NPM version Build Status Coverage Status dependencies Status devDependencies Status Status

asset-resolver

Helper module to find an asset in a set of locations

Install

$ npm install --save asset-resolver

Usage

const resolver = require('asset-resolver');

resolver.getResource('my.svg', {
  base: ['some/directory', 'http://some.domain/assets']
}).then(function(resource) {
  console.log(resource)
});
//=> { path: http://some.domain/assets/my.svg', mime: 'image/svg+xml', contents: ' ... ' }

API

resolver(input, [options])

input
  • Type: string

The filename

options
base
  • Type: string, array
  • Default: [process.cwd()]
  • Required: false
  • Example: ['http://domain.de/', 'http://domain.de/styles', 'app/images', '**/images/']

List of directories/URLs where we should start looking for assets (supports globbing on directories).

filter
  • Type: function

  • Default: function(){ return true; }

  • Required: false

  • Example:

    resolver.getResource('my.svg',{
      base: ['some/directory', 'http://some.domain/assets'],
      filter: function (resource) {
        return filesize(resource) < maxFileSize;
      }
    }).then(function(resource) {
      console.log(resource)
    });
    

List of directories/URLs where we should start looking for assets.

CLI

$ npm install --global asset-resolver
$ asset-resolver --help

  Usage
    asset-resolver [input]

  Options
    -b --base  List of directories/URLs where we should start looking for assets. [Default: process.cwd()]

  Examples
    $ asset-resolver 'my.svg' -b 'some/directory' -b 'http://some.domain/assets'
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <svg>
    ...
    </svg>

License

MIT © Ben Zörb

Keywords

FAQs

Package last updated on 27 Dec 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