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

webext-schema

Package Overview
Dependencies
Maintainers
1
Versions
190
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webext-schema - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

59

modules/schema.js

@@ -277,61 +277,2 @@ /**

/**
* arrange schema to fit specific application
* @param {Object} opt - options
* @param {string} opt.name - app name
* @returns {*} - arranged schema
*/
arrange(opt = {}) {
const {name} = opt;
if (!isString(name)) {
throw new TypeError(`Expected String but got ${getType(name)}.`);
}
const schemas = this._parseSchemaContent();
let schema;
if (name === "sinon-chrome") {
const items = Object.entries(schemas);
const arr = [];
for (const [key, item] of items) {
const subItems = Object.values(item);
for (const subItem of subItems) {
const schemaItems = Object.entries(subItem);
for (const [schemaKey, schemaKeyValue] of schemaItems) {
if (schemaKey === "namespace") {
const camelizedKey = camelize(key.replace(/\.json$/, ""));
const camelizedSchemaKey = camelize(schemaKeyValue);
if (camelizedKey === camelizedSchemaKey ||
camelizedSchemaKey.startsWith(camelizedKey) ||
camelizedKey.startsWith(camelizedSchemaKey)) {
arr.push(subItem);
}
}
}
}
}
schema = [];
for (const item of arr) {
const {events, functions, namespace, types} = item;
if (events || functions) {
if (namespace === "menus") {
if (types) {
const menusChild = this.get("menus_child.json");
const [{functions: menusChildFunctions}] = menusChild;
const contextMenus = Object.assign({}, item);
contextMenus.namespace = "contextMenus";
contextMenus.permissions = "contextMenus";
for (const func of menusChildFunctions) {
functions.push(func);
}
schema.push(contextMenus);
schema.push(item);
}
} else {
schema.push(item);
}
}
}
}
return schema || null;
}
/**
* get schema

@@ -338,0 +279,0 @@ * @param {string} name - API name or file name

5

package.json

@@ -35,6 +35,5 @@ {

"mocha": "^7.0.1",
"nyc": "^15.0.0",
"sinon-chrome": "^3.0.1"
"nyc": "^15.0.0"
},
"version": "1.0.2"
"version": "1.1.0"
}

@@ -55,19 +55,2 @@ [![Build Status](https://travis-ci.org/asamuzaK/webext-schema.svg?branch=master)](https://travis-ci.org/asamuzaK/webext-schema)

### schema.arrange(<var>opt</var>)
* @param {Object} opt - options
* @param {string} opt.name - application name
* @returns {*} - arranged schema
Get the arranged schema for the specific application.
Supported applications:
* [sinon-chrome](https://www.npmjs.com/package/sinon-chrome)
```
const schema = new Schema().arrange({name: "sinon-chrome"});
// [{namespace: "alarms", functions: [{...}], ...}];
```
### schema.get(<var>name</var>)

@@ -74,0 +57,0 @@

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