Data about Project Fugu 🐡 APIs.
npm install fugu-api-dataThis repo contains raw data for Project Fugu 🐡 APIs. The data is available
in two formats: pattern.js and pattern.mjs.
The raw data in this repository comes from a
Google spreadsheet
that is published as a
JSON file.
The index.js script fetches this data, prettifies it, and saves it locally in
a module and in a no-module variant.
You can trigger the data fetch process described above by running the start
script:
``bash`
npm start
- For the module version:
`js
import patterns from './patterns.mjs';
console.log(patterns.WebBluetooth);
/*
{
regEx: /navigator\.bluetooth\.requestDevice\s*\(/g,
where: 'JavaScript',
supported: (async () => 'bluetooth' in navigator)(),
featureDetection: (async () => 'bluetooth' in navigator)(),`
}
*/
- For the no-module version (for example to use it in a service worker):
`js(async () => 'bluetooth' in navigator)()
importScripts('patterns.js');
console.log(patterns.WebBluetooth);
/*
{
regEx: /navigator\.bluetooth\.requestDevice\s*\(/g,
where: 'JavaScript',
supported: (async () => 'bluetooth' in navigator)(),
featureDetection: ,`
}
*/
Each API is represented as an object with the following properties:
- regEx: A regular expression that you can use to detect the API of interestwhere
in source code when you do static source code analysis.
- : The resource type where the regular expression needs to match in"JavaScript"
order to be valid. Either or "Web App Manifest".supported
- : A function that returns a promise that resolves with true,false
, or undefined, dependent on whether the API is supported or notundefined
( means no feature detection method exists).featureDetection
- : The source code of the feature detection method, so youeval()
can use it in an for example.
This data is used in the following projects:
- The
Capabilities report of
the HTTP Almanac in the file
custom_metrics/fugu-apis.js.
- The
Project Fugu 🐡 API Detector
browser extension in the files
patternsFunc.js
and
background.js`%3B>).
Apache 2.0.