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

framework-utils

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

framework-utils - npm Package Compare versions

Comparing version 0.3.4 to 1.0.0

32

declaration/index.d.ts

@@ -6,21 +6,27 @@ export declare function prefixNames(prefix: string, ...classNames: string[]): string;

export declare function Properties(properties: any[], action: (prototype: any, property: string) => any): (component: any) => void;
export declare function withMethods(methods: string[], duplicate?: {
export declare function withMethods(methods: readonly string[], duplicate?: {
[name: string]: string;
}): (prototype: any, propertyName: string) => void;
export declare type ParametersType<T, R> = T extends (...params: infer U) => any ? (...params: U) => R : never;
export declare type ExcludeInterface<T, U> = {
[key in (Exclude<keyof T, keyof U>)]: T[key];
export declare type ParametersType<Func, Return> = Func extends (...params: infer Params) => any ? (...params: Params) => Return : never;
export declare type ExcludeInterface<Obj1, Obj2> = {
[key in Exclude<keyof Obj1, keyof Obj2>]: Obj1[key];
};
export declare type Entries<T extends {
export declare type Entries<Obj extends {
[key: string]: any;
}, U = keyof T> = U extends string ? [U, T[U]] : never;
export declare type ReverseKey<T extends string, U extends {
}, Key = keyof Obj> = Key extends string ? [Key, Obj[Key]] : never;
export declare type ReverseKey<Key extends string, Obj extends {
[key: string]: any;
}, E = Entries<U>> = E extends [infer K, T] ? K : never;
export declare type MethodInterface<T, U extends T, R extends any, Duplicate extends {
}, E = Entries<Obj>> = E extends [infer Value, Key] ? Value : never;
export declare type UniqueMethodInterface<Methods, Target extends Methods, ReturnTarget extends any, Duplicate extends {
[key: string]: any;
} = {}> = {
[key in keyof ExcludeInterface<T, Duplicate>]: T[key] extends (...params: any[]) => U ? ParametersType<T[key], R> : T[key];
} & {
[key in Duplicate[keyof Duplicate]]: T[ReverseKey<key, Duplicate> & keyof T] extends (...params: any[]) => U ? ParametersType<T[ReverseKey<key, Duplicate> & keyof T], R> : T[ReverseKey<key, Duplicate> & keyof T];
}> = {
[key in keyof ExcludeInterface<Methods, Duplicate>]: Methods[key] extends (...params: any[]) => Target ? ParametersType<Methods[key], ReturnTarget> : Methods[key];
};
export declare type ChangedMethodInterface<Methods, Target extends Methods, ReturnTarget extends any, Duplicate extends {
[key: string]: any;
}> = {
[key in Duplicate[keyof Duplicate]]: Methods[ReverseKey<key, Duplicate> & keyof Methods] extends (...params: any[]) => Target ? ParametersType<Methods[ReverseKey<key, Duplicate> & keyof Methods], ReturnTarget> : Methods[ReverseKey<key, Duplicate> & keyof Methods];
};
export declare type MethodInterface<Methods, Target extends Methods, ReturnTarget extends any, Duplicate extends {
[key: string]: any;
} = {}> = UniqueMethodInterface<Methods, Target, ReturnTarget, Duplicate> & ChangedMethodInterface<Methods, Target, ReturnTarget, Duplicate>;

@@ -7,3 +7,3 @@ /*

repository: git+https://github.com/daybrush/framework-utils.git
version: 0.3.4
version: 1.0.0
*/

@@ -26,3 +26,3 @@ 'use strict';

function prefixCSS(prefix, css) {
return css.replace(/([^}{]*){/mg, function (_, selector) {
return css.replace(/([^}{]*){/gm, function (_, selector) {
return selector.replace(/\.([^{,\s\d.]+)/g, "." + prefix + "$1") + "{";

@@ -64,3 +64,3 @@ });

if (prototype[methodName]) {
if (methodName in prototype) {
return;

@@ -67,0 +67,0 @@ }

@@ -7,3 +7,3 @@ /*

repository: git+https://github.com/daybrush/framework-utils.git
version: 0.3.4
version: 1.0.0
*/

@@ -24,3 +24,3 @@ function prefixNames(prefix) {

function prefixCSS(prefix, css) {
return css.replace(/([^}{]*){/mg, function (_, selector) {
return css.replace(/([^}{]*){/gm, function (_, selector) {
return selector.replace(/\.([^{,\s\d.]+)/g, "." + prefix + "$1") + "{";

@@ -62,3 +62,3 @@ });

if (prototype[methodName]) {
if (methodName in prototype) {
return;

@@ -65,0 +65,0 @@ }

{
"name": "framework-utils",
"version": "0.3.4",
"version": "1.0.0",
"description": "utils for framework",

@@ -5,0 +5,0 @@ "main": "./dist/utils.cjs.js",

export function prefixNames(prefix: string, ...classNames: string[]) {
return classNames.map(
className => className.split(" ").map(name => name ? `${prefix}${name}` : "").join(" "),
).join(" ");
return classNames
.map((className) =>
className
.split(" ")
.map((name) => (name ? `${prefix}${name}` : ""))
.join(" ")
)
.join(" ");
}
export function prefixCSS(prefix: string, css: string) {
return css.replace(/([^}{]*){/mg, (_, selector) => {
return css.replace(/([^}{]*){/gm, (_, selector) => {
return `${selector.replace(/\.([^{,\s\d.]+)/g, `.${prefix}$1`)}{`;

@@ -26,7 +31,10 @@ });

/* Class Decorator */
export function Properties(properties: any[], action: (prototype: any, property: string) => any) {
export function Properties(
properties: any[],
action: (prototype: any, property: string) => any
) {
return (component: any) => {
const prototype = component.prototype;
properties.forEach(property => {
properties.forEach((property) => {
action(prototype, property);

@@ -38,11 +46,14 @@ });

/* Property Decorator */
export function withMethods(methods: string[], duplicate: { [name: string]: string } = {}) {
export function withMethods(
methods: readonly string[],
duplicate: { [name: string]: string } = {}
) {
return (prototype: any, propertyName: string) => {
methods.forEach(name => {
methods.forEach((name) => {
const methodName = duplicate[name] || name;
if (prototype[methodName]) {
if (methodName in prototype) {
return;
}
prototype[methodName] = function(...args) {
prototype[methodName] = function (...args) {
const result = this[propertyName][name](...args);

@@ -60,18 +71,57 @@

export type ParametersType<T, R> = T extends (...params: infer U) => any ? (...params: U) => R : never;
export type ExcludeInterface<T, U> = {
[key in (Exclude<keyof T, keyof U>)]: T[key];
export type ParametersType<Func, Return> = Func extends (
...params: infer Params
) => any
? (...params: Params) => Return
: never;
export type ExcludeInterface<Obj1, Obj2> = {
[key in Exclude<keyof Obj1, keyof Obj2>]: Obj1[key];
};
export type Entries<T extends { [key: string]: any }, U = keyof T> = U extends string ? [U, T[U]] : never;
export type ReverseKey<T extends string, U extends { [key: string]: any }, E = Entries<U>>
= E extends [infer K, T] ? K : never;
export type MethodInterface<T, U extends T, R extends any, Duplicate extends { [key: string]: any } = {}> = {
[key in keyof ExcludeInterface<T, Duplicate>]:
T[key] extends (...params: any[]) => U ? ParametersType<T[key], R> : T[key];
} & {
[key in Duplicate[keyof Duplicate]]:
T[ReverseKey<key, Duplicate> & keyof T] extends (...params: any[]) => U
? ParametersType<T[ReverseKey<key, Duplicate> & keyof T], R>
: T[ReverseKey<key, Duplicate> & keyof T];
export type Entries<
Obj extends { [key: string]: any },
Key = keyof Obj
> = Key extends string ? [Key, Obj[Key]] : never;
export type ReverseKey<
Key extends string,
Obj extends { [key: string]: any },
E = Entries<Obj>
> = E extends [infer Value, Key] ? Value : never;
export type UniqueMethodInterface<
Methods,
Target extends Methods,
ReturnTarget extends any,
Duplicate extends { [key: string]: any }
> = {
[key in keyof ExcludeInterface<Methods, Duplicate>]: Methods[key] extends (
...params: any[]
) => Target
? ParametersType<Methods[key], ReturnTarget>
: Methods[key];
};
export type ChangedMethodInterface<
Methods,
Target extends Methods,
ReturnTarget extends any,
Duplicate extends { [key: string]: any }
> = {
[key in Duplicate[keyof Duplicate]]: Methods[ReverseKey<key, Duplicate> &
keyof Methods] extends (...params: any[]) => Target
? ParametersType<
Methods[ReverseKey<key, Duplicate> & keyof Methods],
ReturnTarget
>
: Methods[ReverseKey<key, Duplicate> & keyof Methods];
};
export type MethodInterface<
Methods,
Target extends Methods,
ReturnTarget extends any,
Duplicate extends { [key: string]: any } = {}
> = UniqueMethodInterface<Methods, Target, ReturnTarget, Duplicate> &
ChangedMethodInterface<Methods, Target, ReturnTarget, Duplicate>;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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