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

@platform/util.string

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@platform/util.string - npm Package Compare versions

Comparing version 0.0.28 to 0.0.29

lib/fuzzy/fuzzy.d.ts

4

lib/index.d.ts

@@ -1,2 +0,2 @@

export * from './convert';
export * from './wildcard';
import * as str from './str';
export { str };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
tslib_1.__exportStar(require("./convert"), exports);
tslib_1.__exportStar(require("./wildcard"), exports);
var str = require("./str");
exports.str = str;

@@ -1,2 +0,2 @@

export declare function matchesWildcard(inputs: string[], patterns: string[] | undefined | null): string[];
export declare function isWildcardMatch(input: string, pattern: string | undefined | null): boolean;
export declare function filter(patterns: string | string[] | undefined | null, inputs: string[]): string[];
export declare function isMatch(input: string, pattern: string | undefined | null): boolean;

@@ -5,6 +5,7 @@ "use strict";

var cache = new Map();
function matchesWildcard(inputs, patterns) {
function filter(patterns, inputs) {
if (patterns === undefined || patterns === null) {
return [];
}
patterns = Array.isArray(patterns) ? patterns : [patterns];
if (!(Array.isArray(inputs) && Array.isArray(patterns))) {

@@ -34,7 +35,7 @@ throw new TypeError("Expected two arrays, got " + typeof inputs + " " + typeof patterns);

}
exports.matchesWildcard = matchesWildcard;
function isWildcardMatch(input, pattern) {
exports.filter = filter;
function isMatch(input, pattern) {
return pattern === undefined || pattern === null ? false : makeRegEx(pattern, true).test(input);
}
exports.isWildcardMatch = isWildcardMatch;
exports.isMatch = isMatch;
function makeRegEx(pattern, shouldNegate) {

@@ -41,0 +42,0 @@ var cacheKey = pattern + shouldNegate;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var chai_1 = require("chai");
var str = require(".");
var ramda_1 = require("ramda");
var __1 = require("..");
describe('wildcard', function () {
it('isWildcardMatch', function () {
chai_1.expect(str.isWildcardMatch('bath', 'ba*')).to.eql(true);
chai_1.expect(__1.str.wildcard.isMatch('bath', 'ba*')).to.eql(true);
});
it('matches multiple values', function () {
var result = str.matchesWildcard(['bath', 'batty', 'zoo'], ['ba*']);
chai_1.expect(result).to.eql(['bath', 'batty']);
it('filters multiple values (single pattern)', function () {
var res = __1.str.wildcard.filter('ba*', ['bath', 'batty', 'zoo']);
chai_1.expect(res).to.eql(['bath', 'batty']);
});
it('filters multiple values', function () {
var res = __1.str.wildcard.filter(['ba*', 'z*'], ['bath', 'batty', 'zoo', 'camel']);
chai_1.expect(res).to.eql(['bath', 'batty', 'zoo']);
});
it('currys the match filter', function () {
var filter = ramda_1.curry(__1.str.wildcard.filter);
var ba = filter('ba*');
var res = ba(['bath', 'batty', 'zoo']);
chai_1.expect(res).to.eql(['bath', 'batty']);
});
});
{
"name": "@platform/util.string",
"version": "0.0.28",
"version": "0.0.29",
"description": "String helpers.",

@@ -8,13 +8,13 @@ "main": "lib/index",

"scripts": {
"test": "yarn chmod && ts test",
"tdd": "yarn chmod && ts test --watch",
"lint": "yarn chmod && ts lint",
"build": "yarn chmod && ts build",
"prepare": "yarn chmod && ts prepare",
"chmod": "chmod 777 node_modules/.bin/ts"
"test": "ts test",
"tdd": "ts test --watch",
"lint": "ts lint",
"build": "ts build",
"prepare": "ts prepare"
},
"dependencies": {
"@types/underscore.string": "^0.0.35",
"escape-string-regexp": "^1.0.5",
"underscore.string": "^3.3.5"
"@types/underscore.string": "0.0.35",
"escape-string-regexp": "1.0.5",
"fuzzy": "0.1.3",
"underscore.string": "3.3.5"
},

@@ -24,3 +24,3 @@ "devDependencies": {

"@platform/ts": "3.3.59",
"@types/escape-string-regexp": "^1.0.0"
"@types/escape-string-regexp": "1.0.0"
},

@@ -27,0 +27,0 @@ "files": [

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