Socket
Book a DemoInstallSign in
Socket

@ionic/jpml

Package Overview
Dependencies
Maintainers
13
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ionic/jpml

Wrap any file content within jsonp callback

latest
Source
npmnpm
Version
0.0.5
Version published
Weekly downloads
21
31.25%
Maintainers
13
Weekly downloads
 
Created
Source

Simple JSONP Content Wrapper

We have a use case (Ionicons) where the browser needs to request svg content which can be loaded cross-origin, or from the file:// protocol. This project will take a directory(s) of files and wrap file contents in a JSONP callback. This allows the JSONP handler to receive the text cross-origin.

import * as jpml from '@ionic/jpml`;


// generate jsonp callback files from a list of directories
jpml.generate({
  // array of all the paths to include
  include: ['some/input/path/'],

  // where all the output files will be saved
  outDir: 'some/output/path',

  // filter function to test which files to generate from
  filter: function(path) {
    // returns true if the path ends with ".svg"
    return path.split('.').pop() === 'svg';
  },

  // function to generate each file's content
  wrapper: function(content, key) {
    return 'loadContent("' + content + '", "' + key + '");'
  }
});

Keywords

svg

FAQs

Package last updated on 14 Nov 2017

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