Socket
Socket
Sign inDemoInstall

@ui5/fs

Package Overview
Dependencies
Maintainers
4
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ui5/fs - npm Package Compare versions

Comparing version 3.0.0-alpha.0 to 3.0.0-alpha.1

lib/readers/Filter.js

9

CHANGELOG.md

@@ -5,4 +5,10 @@ # Changelog

A list of unreleased changes can be found [here](https://github.com/SAP/ui5-fs/compare/v3.0.0-alpha.0...HEAD).
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-fs/compare/v3.0.0-alpha.1...HEAD).
<a name="v3.0.0-alpha.1"></a>
## [v3.0.0-alpha.1] - 2022-01-13
### Features
- Introduce Readers "Filter" and "Transformer" ([#331](https://github.com/SAP/ui5-fs/issues/331)) [`f46e6d1`](https://github.com/SAP/ui5-fs/commit/f46e6d1b9aed5858f2d72b10b18635de6ed1f1e0)
<a name="v3.0.0-alpha.0"></a>

@@ -135,2 +141,3 @@ ## [v3.0.0-alpha.0] - 2021-12-14

[v3.0.0-alpha.1]: https://github.com/SAP/ui5-fs/compare/v3.0.0-alpha.0...v3.0.0-alpha.1
[v3.0.0-alpha.0]: https://github.com/SAP/ui5-fs/compare/v2.0.6...v3.0.0-alpha.0

@@ -137,0 +144,0 @@ [v2.0.6]: https://github.com/SAP/ui5-fs/compare/v2.0.5...v2.0.6

@@ -26,2 +26,17 @@ /**

/**
* @public
* @alias module:@ui5/fs.readers
* @namespace
*/
readers: {
/**
* @type {typeof import('./lib/readers/Filter')}
*/
Filter: "./lib/readers/Filter",
/**
* @type {typeof import('./lib/readers/Transformer')}
*/
Transformer: "./lib/readers/Transformer",
},
/**
* @type {typeof import('./lib/AbstractReader')}

@@ -28,0 +43,0 @@ */

@@ -73,3 +73,36 @@ const randomInt = require("random-int");

/**
* Create a [Filter-Reader]{@link module:@ui5/fs.readers.Filter} from the current reader
*
* @public
* @param {module:@ui5/fs.readers.Filter~callback} callback
* Filter function. Will be called for every resource passed through this reader.
* @returns {module:@ui5/fs.reader.Filter} Filter instance
*/
filter(callback) {
const Filter = require("./readers/Filter");
return new Filter({
reader: this,
callback
});
}
/**
* Create a [Transform-Reader]{@link module:@ui5/fs.readers.Transform} from the current reader
*
* @public
* @param {module:@ui5/fs.readers.Transformer~callback} callback
* Callback to check and eventually transform any resource passed through the reader
* @returns {module:@ui5/fs.reader.Transformer} Transformer instance
*/
transformer(callback) {
const Transformer = require("./readers/Transformer");
return new Transformer({
reader: this,
callback
});
}
/**
* Locates resources by one or more glob patterns.

@@ -76,0 +109,0 @@ *

50

lib/ResourceTagCollection.js

@@ -5,6 +5,14 @@ const tagNamespaceRegExp = new RegExp("^[a-z][a-z0-9]*$"); // part before the colon

class ResourceTagCollection {
constructor({allowedTags}) {
constructor({allowedTags, superCollection}) {
if (!allowedTags || !allowedTags.length) {
throw new Error(`Missing parameter 'allowedTags'`);
}
if (superCollection) {
this._superCollection = superCollection;
this._superTags = this._superCollection.getAcceptedTags();
} else {
this._superTags = [];
}
// No validation of tag names here since we might remove/ignore

@@ -16,8 +24,11 @@ // this parameter in the future and generally allow all tags

setTag(resource, tag, value = true) {
this._validateResource(resource);
setTag(resourcePath, tag, value = true) {
if (this._superTags.includes(tag)) {
return this._superCollection.setTag(resourcePath, tag, value);
}
resourcePath = this._getPath(resourcePath);
this._validateTag(tag);
this._validateValue(value);
const resourcePath = resource.getPath();
if (!this._pathTags[resourcePath]) {

@@ -29,7 +40,10 @@ this._pathTags[resourcePath] = {};

clearTag(resource, tag) {
this._validateResource(resource);
clearTag(resourcePath, tag) {
if (this._superTags.includes(tag)) {
return this._superCollection.clearTag(resourcePath, tag);
}
resourcePath = this._getPath(resourcePath);
this._validateTag(tag);
const resourcePath = resource.getPath();
if (this._pathTags[resourcePath]) {

@@ -40,7 +54,10 @@ this._pathTags[resourcePath][tag] = undefined;

getTag(resource, tag) {
this._validateResource(resource);
getTag(resourcePath, tag) {
if (this._superTags.includes(tag)) {
return this._superCollection.getTag(resourcePath, tag);
}
resourcePath = this._getPath(resourcePath);
this._validateTag(tag);
const resourcePath = resource.getPath();
if (this._pathTags[resourcePath]) {

@@ -51,7 +68,14 @@ return this._pathTags[resourcePath][tag];

_validateResource(resource) {
const path = resource.getPath();
if (!path) {
getAcceptedTags() {
return [...this._allowedTags, ...this._superTags];
}
_getPath(resourcePath) {
if (typeof resourcePath !== "string") {
resourcePath = resourcePath.getPath();
}
if (!resourcePath) {
throw new Error(`Invalid Resource: Resource path must not be empty`);
}
return resourcePath;
}

@@ -58,0 +82,0 @@

{
"name": "@ui5/fs",
"version": "3.0.0-alpha.0",
"version": "3.0.0-alpha.1",
"description": "UI5 Tooling - File System Abstraction",

@@ -106,3 +106,3 @@ "author": {

"dependencies": {
"@ui5/logger": "^3.0.0-alpha.0",
"@ui5/logger": "^3.0.1-alpha.0",
"clone": "^2.1.0",

@@ -109,0 +109,0 @@ "globby": "^11.0.4",

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