@finnair/path
Advanced tools
Comparing version 4.0.0 to 5.0.0
@@ -6,2 +6,24 @@ # Change Log | ||
# [5.0.0](https://github.com/finnair/v-validation/compare/v4.3.0...v5.0.0) (2023-10-13) | ||
### Features | ||
* use ECMAScript modules (ESM) instead of CommonJS ([#95](https://github.com/finnair/v-validation/issues/95)) ([92e9118](https://github.com/finnair/v-validation/commit/92e9118235957ec4bc2bcf2de73e195ea940378c)) | ||
# [5.0.0](https://github.com/finnair/v-validation/compare/v4.3.0...v5.0.0) (2023-10-13) | ||
### Features | ||
* use ECMAScript modules (ESM) instead of CommonJS ([#95](https://github.com/finnair/v-validation/issues/95)) ([92e9118](https://github.com/finnair/v-validation/commit/92e9118235957ec4bc2bcf2de73e195ea940378c)) | ||
# [4.0.0](https://github.com/finnair/v-validation/compare/v3.2.0...v4.0.0) (2022-11-07) | ||
@@ -8,0 +30,0 @@ |
@@ -1,4 +0,4 @@ | ||
export { Path, PathComponent } from './Path'; | ||
export * from './PathMatcher'; | ||
export * from './matchers'; | ||
export * from './Projection'; | ||
export { Path, PathComponent } from './Path.js'; | ||
export * from './PathMatcher.js'; | ||
export * from './matchers.js'; | ||
export * from './Projection.js'; |
@@ -1,22 +0,4 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Path = void 0; | ||
var Path_1 = require("./Path"); | ||
Object.defineProperty(exports, "Path", { enumerable: true, get: function () { return Path_1.Path; } }); | ||
__exportStar(require("./PathMatcher"), exports); | ||
__exportStar(require("./matchers"), exports); | ||
__exportStar(require("./Projection"), exports); | ||
export { Path } from './Path.js'; | ||
export * from './PathMatcher.js'; | ||
export * from './matchers.js'; | ||
export * from './Projection.js'; |
@@ -1,3 +0,3 @@ | ||
import { Path, PathComponent } from './Path'; | ||
declare type Continue = boolean; | ||
import { Path, PathComponent } from './Path.js'; | ||
type Continue = boolean; | ||
export interface MatchHandler { | ||
@@ -4,0 +4,0 @@ (value: any, component: PathComponent): Continue; |
@@ -1,10 +0,8 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AnyProperty = exports.AnyIndex = exports.UnionMatcher = exports.PropertyMatcher = exports.IndexMatcher = exports.Node = exports.isPathExpression = void 0; | ||
const Path_1 = require("./Path"); | ||
function isPathExpression(component) { | ||
import { Path } from './Path.js'; | ||
export function isPathExpression(component) { | ||
return !!component && typeof component.test === 'function' && typeof component.find === 'function'; | ||
} | ||
exports.isPathExpression = isPathExpression; | ||
class Node { | ||
export class Node { | ||
path; | ||
value; | ||
constructor(path, value) { | ||
@@ -15,8 +13,8 @@ this.path = path; | ||
} | ||
exports.Node = Node; | ||
class IndexMatcher { | ||
export class IndexMatcher { | ||
index; | ||
allowGaps = true; | ||
constructor(index) { | ||
this.index = index; | ||
this.allowGaps = true; | ||
Path_1.Path.validateIndex(index); | ||
Path.validateIndex(index); | ||
} | ||
@@ -33,11 +31,11 @@ find(current, callback) { | ||
toString() { | ||
return Path_1.Path.indexToString(this.index); | ||
return Path.indexToString(this.index); | ||
} | ||
} | ||
exports.IndexMatcher = IndexMatcher; | ||
class PropertyMatcher { | ||
export class PropertyMatcher { | ||
property; | ||
allowGaps = false; | ||
constructor(property) { | ||
this.property = property; | ||
this.allowGaps = false; | ||
Path_1.Path.validateProperty(property); | ||
Path.validateProperty(property); | ||
} | ||
@@ -54,7 +52,7 @@ find(current, callback) { | ||
toString() { | ||
return Path_1.Path.propertyToString(this.property); | ||
return Path.propertyToString(this.property); | ||
} | ||
} | ||
exports.PropertyMatcher = PropertyMatcher; | ||
class UnionMatcher { | ||
export class UnionMatcher { | ||
components; | ||
constructor(components) { | ||
@@ -65,3 +63,3 @@ this.components = components; | ||
} | ||
components.forEach(Path_1.Path.validateComponent); | ||
components.forEach(Path.validateComponent); | ||
} | ||
@@ -97,4 +95,3 @@ find(current, callback) { | ||
} | ||
exports.UnionMatcher = UnionMatcher; | ||
exports.AnyIndex = { | ||
export const AnyIndex = { | ||
allowGaps: false, | ||
@@ -118,3 +115,3 @@ find: (current, callback) => { | ||
}; | ||
exports.AnyProperty = { | ||
export const AnyProperty = { | ||
allowGaps: false, | ||
@@ -121,0 +118,0 @@ find: (current, callback) => { |
@@ -1,2 +0,2 @@ | ||
export declare type PathComponent = number | string; | ||
export type PathComponent = number | string; | ||
export declare class Path { | ||
@@ -3,0 +3,0 @@ static readonly ROOT: Path; |
@@ -1,6 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Path = void 0; | ||
const identifierPattern = /^[a-zA-Z_][a-zA-Z0-9_]*$/; | ||
class Path { | ||
export class Path { | ||
static ROOT = new Path([]); | ||
path; | ||
constructor(path) { | ||
@@ -163,3 +162,1 @@ this.path = path; | ||
} | ||
exports.Path = Path; | ||
Path.ROOT = new Path([]); |
@@ -1,3 +0,3 @@ | ||
import { Path, PathComponent } from './Path'; | ||
import { Node, PathExpression, PropertyMatcher, IndexMatcher, AnyIndex, AnyProperty, UnionMatcher } from './matchers'; | ||
import { Path, PathComponent } from './Path.js'; | ||
import { Node, PathExpression, PropertyMatcher, IndexMatcher, AnyIndex, AnyProperty, UnionMatcher } from './matchers.js'; | ||
export declare class PathMatcher { | ||
@@ -4,0 +4,0 @@ private readonly expressions; |
@@ -1,13 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.UnionMatcher = exports.Node = exports.IndexMatcher = exports.PropertyMatcher = exports.AnyProperty = exports.AnyIndex = exports.PathMatcher = void 0; | ||
const Path_1 = require("./Path"); | ||
const matchers_1 = require("./matchers"); | ||
Object.defineProperty(exports, "Node", { enumerable: true, get: function () { return matchers_1.Node; } }); | ||
Object.defineProperty(exports, "PropertyMatcher", { enumerable: true, get: function () { return matchers_1.PropertyMatcher; } }); | ||
Object.defineProperty(exports, "IndexMatcher", { enumerable: true, get: function () { return matchers_1.IndexMatcher; } }); | ||
Object.defineProperty(exports, "AnyIndex", { enumerable: true, get: function () { return matchers_1.AnyIndex; } }); | ||
Object.defineProperty(exports, "AnyProperty", { enumerable: true, get: function () { return matchers_1.AnyProperty; } }); | ||
Object.defineProperty(exports, "UnionMatcher", { enumerable: true, get: function () { return matchers_1.UnionMatcher; } }); | ||
class PathMatcher { | ||
import { Path } from './Path.js'; | ||
import { Node, PropertyMatcher, IndexMatcher, AnyIndex, AnyProperty, UnionMatcher, isPathExpression } from './matchers.js'; | ||
export class PathMatcher { | ||
expressions; | ||
allowGaps; | ||
constructor(expressions) { | ||
@@ -23,3 +16,3 @@ this.expressions = expressions; | ||
if (this.expressions.length === 0) { | ||
return [new matchers_1.Node(Path_1.Path.ROOT, root)]; | ||
return [new Node(Path.ROOT, root)]; | ||
} | ||
@@ -46,3 +39,3 @@ if (typeof root !== 'object') { | ||
return (value, component) => { | ||
results.push(new matchers_1.Node(Path_1.Path.of(...currentPath, component), value)); | ||
results.push(new Node(Path.of(...currentPath, component), value)); | ||
return !first; | ||
@@ -125,8 +118,8 @@ }; | ||
if (type === 'number') { | ||
return new matchers_1.IndexMatcher(component); | ||
return new IndexMatcher(component); | ||
} | ||
if (type === 'string') { | ||
return new matchers_1.PropertyMatcher(component); | ||
return new PropertyMatcher(component); | ||
} | ||
if ((0, matchers_1.isPathExpression)(component)) { | ||
if (isPathExpression(component)) { | ||
return component; | ||
@@ -138,2 +131,2 @@ } | ||
} | ||
exports.PathMatcher = PathMatcher; | ||
export { AnyIndex, AnyProperty, PropertyMatcher, IndexMatcher, Node, UnionMatcher }; |
@@ -1,3 +0,3 @@ | ||
import { PathMatcher } from './PathMatcher'; | ||
import { Path } from './Path'; | ||
import { PathMatcher } from './PathMatcher.js'; | ||
import { Path } from './Path.js'; | ||
export declare class Projection { | ||
@@ -4,0 +4,0 @@ private readonly includes; |
@@ -1,6 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.projection = exports.Projection = void 0; | ||
const PathMatcher_1 = require("./PathMatcher"); | ||
class Projection { | ||
import { PathMatcher } from './PathMatcher.js'; | ||
export class Projection { | ||
includes; | ||
excludes; | ||
allowGaps; | ||
constructor(includes, excludes, allowGaps) { | ||
@@ -52,10 +52,8 @@ this.includes = includes; | ||
} | ||
exports.Projection = Projection; | ||
function projection(includes, excludes) { | ||
export function projection(includes, excludes) { | ||
const projection = Projection.of(includes, excludes); | ||
return (input) => projection.map(input); | ||
} | ||
exports.projection = projection; | ||
function validatePathMatcher(value) { | ||
if (value instanceof PathMatcher_1.PathMatcher) { | ||
if (value instanceof PathMatcher) { | ||
return value; | ||
@@ -62,0 +60,0 @@ } |
{ | ||
"name": "@finnair/path", | ||
"version": "4.0.0", | ||
"version": "5.0.0", | ||
"private": false, | ||
"description": "Simple object path as array of strings and numbers", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
} | ||
} | ||
}, | ||
"license": "MIT", | ||
@@ -25,3 +32,3 @@ "homepage": "https://github.com/finnair/v-validation/tree/master/packages/path#readme", | ||
}, | ||
"gitHead": "d6540b51c4f1c57563602f66bd3157637703529b" | ||
"gitHead": "b20762715a79e2a336f9c8ceb5107a4d84104a14" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Yes
38272
610