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

@matchlighter/common_library

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@matchlighter/common_library - npm Package Compare versions

Comparing version 1.0.0 to 1.2.1

lib/components/shadowed_scroll/index.d.ts

5

lib/decorators/catch.d.ts
declare type HandlerFunction<T> = (error: any, ctx: T) => void;
declare type CatchDecorator<T> = (object: T, key: string, desc: PropertyDescriptor) => PropertyDescriptor;
interface CatchOptions {
export interface CatchOptions {
log: boolean;
inAction: boolean;
}

@@ -10,2 +9,3 @@ export declare function Catch<T>(handler: HandlerFunction<T>, options?: Partial<CatchOptions>): CatchDecorator<T>;

var logger: (e: Error) => void;
var invokeHandler: (handler: any, err: any, ctx: any) => any;
}

@@ -15,3 +15,4 @@ export declare function Catch<T>(errorClass: any, handler: HandlerFunction<T>, options?: Partial<CatchOptions>): CatchDecorator<T>;

var logger: (e: Error) => void;
var invokeHandler: (handler: any, err: any, ctx: any) => any;
}
export {};

21

lib/decorators/catch.js

@@ -1,10 +0,5 @@

import { runInAction } from 'mobx';
function handleError(ctx, errorClass, handler, error, options) {
if (!errorClass || error instanceof errorClass) {
if (options.inAction) {
runInAction(() => handler.call(ctx, error, ctx));
}
else {
handler.call(ctx, error, ctx);
}
// Modified from https://github.com/enkot/catch-decorator
function handleError(ctx, error, options) {
if (!options.errorClass || error instanceof options.errorClass) {
Catch.invokeHandler(options.handler, error, ctx);
if (options.log)

@@ -28,3 +23,4 @@ Catch.logger(error);

}
const options = Object.assign({ log: true, inAction: true }, partialOptions);
const options = Object.assign({ log: true, handler,
errorClass }, partialOptions);
return (target, propertyKey, descriptor) => {

@@ -41,3 +37,3 @@ // save a reference to the original method

return result.catch((error) => {
handleError(this, errorClass, handler, error, options);
handleError(this, error, options);
});

@@ -49,3 +45,3 @@ }

catch (error) {
handleError(this, errorClass, handler, error, options);
handleError(this, error, options);
}

@@ -59,2 +55,3 @@ };

};
Catch.invokeHandler = (handler, err, ctx) => handler.call(ctx, err, ctx);
try {

@@ -61,0 +58,0 @@ const { captureException } = require('@sentry/core');

@@ -17,3 +17,3 @@ import { computed, observable } from 'mobx';

const makeLazyObservable = (self, defaultValue) => lazyObservable((sink) => callback.call(self, sink, self), defaultValue);
return computed(target, propertyKey, Object.assign({ set(value) {
return computed(target, propertyKey, Object.assign(Object.assign({ set(value) {
const state = getPrivateStore(this, LAZY_PROPS);

@@ -23,3 +23,3 @@ if (typeof value == 'object')

state[propertyKey] = makeLazyObservable(this, value);
} }, (descriptor || {}), { get() {
} }, (descriptor || {})), { get() {
const state = getPrivateStore(this, LAZY_PROPS);

@@ -26,0 +26,0 @@ const lazy = state[propertyKey] = state[propertyKey] || makeLazyObservable(this);

@@ -0,1 +1,12 @@

/**
* Method decorator to make render methods MobX Observers.
* Apply to a method that returns a React Element:
*
* ```jsx
* @observerMethod
* renderItem({ observable }) {
* return <div>{observable.value}</div>
* }
* ```
*/
export declare function observerMethod(target: any, key: any, descriptor: any): {

@@ -2,0 +13,0 @@ configurable: boolean;

import React from 'react';
import { observer } from 'mobx-react';
/**
* Method decorator to make render methods MobX Observers.
* Apply to a method that returns a React Element:
*
* ```jsx
* @observerMethod
* renderItem({ observable }) {
* return <div>{observable.value}</div>
* }
* ```
*/
export function observerMethod(target, key, descriptor) {

@@ -4,0 +15,0 @@ let fn = descriptor.value;

@@ -5,3 +5,3 @@ /**

*/
export declare const PromiseOnce: (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
export declare const PromiseOnce: <T>(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
configurable: any;

@@ -8,0 +8,0 @@ enumerable: any;

@@ -0,1 +1,22 @@

/**
* Property Decorator. Apply to a static property that contains an object.
* Subclasses will inherit the property and any top-level keys, but can be assigned to independently
*
* ```js
* class A {
* @InheritedDict static object = { foo: 1, bar: 3 };
* }
*
* class B { }
* B.object['foo'] = 4
* B.object['meh'] = 2
*
* A.object['foo'] // = 1
* B.object['foo'] // = 4
* A.object['meh'] // = undefined
* B.object['meh'] // = 2
* A.object['bar'] // = 3
* B.object['bar'] // = 3
* ```
*/
export declare const InheritedDict: (target: Object, key: string, desc?: PropertyDescriptor) => any;

@@ -0,1 +1,22 @@

/**
* Property Decorator. Apply to a static property that contains an object.
* Subclasses will inherit the property and any top-level keys, but can be assigned to independently
*
* ```js
* class A {
* @InheritedDict static object = { foo: 1, bar: 3 };
* }
*
* class B { }
* B.object['foo'] = 4
* B.object['meh'] = 2
*
* A.object['foo'] // = 1
* B.object['foo'] // = 4
* A.object['meh'] // = undefined
* B.object['meh'] // = 2
* A.object['bar'] // = 3
* B.object['bar'] // = 3
* ```
*/
export const InheritedDict = (target, key, desc) => {

@@ -20,4 +41,8 @@ const prop_key = `_${key}`;

},
set(v) {
const obj = getDictionary.call(this);
Object.assign(obj, v);
}
};
};
//# sourceMappingURL=static_inheritance.js.map

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

export * from './deep_common';
export * from './deep';

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

export * from './deep_common';
export * from './deep';
//# sourceMappingURL=index.js.map

@@ -10,2 +10,7 @@ import { AsyncReturnType } from './promises';

}
/**
* A Class for helping with fetching remote data and tracking status.
* When the object is called (either directly or via .ensure()), it executes the function that was given during construction, and return a Promise
* `state` is transitioned to 'loading' until the function returns, whereon `state` is transitioned to 'loaded' or 'error'.
*/
export declare class EnsureFunction<F extends EFFunc> extends ExtensibleFunction<Parameters<F>, Promise<ReturnType<F>>> {

@@ -12,0 +17,0 @@ constructor(func: F);

@@ -12,2 +12,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

import { ExtensibleFunction } from './extensibleFunction';
/**
* A Class for helping with fetching remote data and tracking status.
* When the object is called (either directly or via .ensure()), it executes the function that was given during construction, and return a Promise
* `state` is transitioned to 'loading' until the function returns, whereon `state` is transitioned to 'loaded' or 'error'.
*/
export class EnsureFunction extends ExtensibleFunction {

@@ -14,0 +19,0 @@ constructor(a, b) {

@@ -6,4 +6,10 @@ interface Constructor<T = {}> {

* Given a Functional constructor (a function that returns an object, but is not meant to be used with `new`), return a Class that can be extended
*
* Example:
* ```js
* const BaseMoment = makeExtensible(moment);
* class SubMoment extends BaseMoment { }
* ```
*/
export declare function makeExtensible<T>(constructCall: (...args: any[]) => T, prototype?: any): Constructor<T>;
export {};
/**
* Given a Functional constructor (a function that returns an object, but is not meant to be used with `new`), return a Class that can be extended
*
* Example:
* ```js
* const BaseMoment = makeExtensible(moment);
* class SubMoment extends BaseMoment { }
* ```
*/

@@ -4,0 +10,0 @@ export function makeExtensible(constructCall, prototype) {

@@ -11,2 +11,5 @@ export declare type PromiseType<T> = T extends Promise<infer U> ? U : T;

}
/**
* A Promise-Like class that can be controlled (resolved/rejected) via a public API
*/
export declare class ControlledPromise<T> extends ExtensiblePromise<T> {

@@ -16,2 +19,2 @@ resolve(p?: T): void;

}
export declare const delay: (ms: any) => Promise<{}>;
export declare const delay: (ms: any) => Promise<unknown>;

@@ -15,2 +15,5 @@ export class ExtensiblePromise {

}
/**
* A Promise-Like class that can be controlled (resolved/rejected) via a public API
*/
export class ControlledPromise extends ExtensiblePromise {

@@ -17,0 +20,0 @@ resolve(p) { this._resolve(p); }

@@ -9,6 +9,25 @@ export declare function toTitleCase(str: string): string;

};
/**
* (Intelligently) Joins multiple parts of a URL.
*
* Accepts strings or ReactRouter `Matches` as URL bits.
*/
export declare function urlJoin(parts: (RouterMatch | string)[]): any;
export declare function urlJoin(...parts: (RouterMatch | string)[]): any;
/**
* Template string tag to (UN-intelligently) join multiple parts of a URL.
* This tag does not attempt to resolve absolute vs relative paths, but instead strips duplicate `/` characters
* if, for example, `http://domain.com/` and `/blah` were joined (resulting in `http://domain.com/blah`).
*
* Accepts strings or ReactRouter `Matches` as URL bits.
*/
export declare const url: (literals: TemplateStringsArray, ...placeholders: (string | RouterMatch)[]) => string;
/**
* Template string tag to split a string into a list of words. Similar to Ruby's `%w[]`
*
* ```js
* words`hello large world` -> ['hello', 'large', 'world']
* ```
*/
export declare const words: (literals: TemplateStringsArray, ...placeholders: string[]) => string[];
export {};

@@ -79,2 +79,9 @@ export function toTitleCase(str) {

}
/**
* Template string tag to (UN-intelligently) join multiple parts of a URL.
* This tag does not attempt to resolve absolute vs relative paths, but instead strips duplicate `/` characters
* if, for example, `http://domain.com/` and `/blah` were joined (resulting in `http://domain.com/blah`).
*
* Accepts strings or ReactRouter `Matches` as URL bits.
*/
export const url = (literals, ...placeholders) => {

@@ -96,2 +103,9 @@ let result = "";

};
/**
* Template string tag to split a string into a list of words. Similar to Ruby's `%w[]`
*
* ```js
* words`hello large world` -> ['hello', 'large', 'world']
* ```
*/
export const words = (literals, ...placeholders) => {

@@ -98,0 +112,0 @@ let result = "";

@@ -5,2 +5,5 @@ import React from "react";

export declare type ClassNamesParam = Parameters<typeof classNames>[0];
/**
* API-enhancing wrapper class for CSS Module classname maps
*/
export declare class StyleSheet extends ExtensibleFunction<[ClassNamesParam, ClassNamesParam?], string> {

@@ -12,2 +15,6 @@ private readonly styles;

}
/**
* Wraps a map of local to global style names (generated by CSS Modules) in a more useful API.
* Same as calling `new StyleSheet(style_map)`.
*/
export declare function styleSheet(...args: ConstructorParameters<typeof StyleSheet>): StyleSheet;

@@ -14,0 +21,0 @@ export declare function extendHTMLElement(classes: string | string[], Element?: string): React.HTMLFactory<HTMLElement>;

import React from "react";
import classNames from 'classnames';
import { ExtensibleFunction } from './extensibleFunction';
/**
* API-enhancing wrapper class for CSS Module classname maps
*/
export class StyleSheet extends ExtensibleFunction {

@@ -22,2 +25,6 @@ constructor(styles) {

}
/**
* Wraps a map of local to global style names (generated by CSS Modules) in a more useful API.
* Same as calling `new StyleSheet(style_map)`.
*/
export function styleSheet(...args) {

@@ -24,0 +31,0 @@ return new StyleSheet(...args);

{
"name": "@matchlighter/common_library",
"version": "1.0.0",
"description": "> TODO: description",
"version": "1.2.1",
"description": "Shared Functions, Helpers, Patterns & Utilities for Apps and Libraries",
"author": "Matchlighter",

@@ -25,20 +25,33 @@ "homepage": "",

"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1",
"build": "tsc"
"test": "jest",
"build": "tsc",
"prepublishOnly": "npm build"
},
"dependencies": {
"classnames": "^2.2.6",
"peerDependencies": {
"jsonpath": "^1.0.2",
"mobx": "^5.13.0",
"mobx-react": "^6.1.3",
"mobx-utils": "^5.4.1",
"react": "^16.9.0",
"react": "^16.9.0"
},
"dependencies": {
"classnames": "^2.2.6",
"underscore": "^1.9.1"
},
"devDependencies": {
"@babel/core": "^7.6.0",
"@babel/preset-env": "^7.6.0",
"@types/jest": "^24.0.18",
"@types/jsonpath": "^0.2.0",
"@types/react": "^16.9.2",
"jest": "^24.9.0",
"ts-jest": "^24.0.2"
},
"gitHead": "5943ccfc741c5a96ebada523deb6abf1a15f80f0"
"jsonpath": "^1.0.2",
"mobx": "^5.13.0",
"mobx-react": "^6.1.3",
"mobx-utils": "^5.4.1",
"react": "^16.9.0",
"ts-jest": "^24.0.2",
"ts-node": "^8.5.4",
"typescript": "^3.6.0"
}
}

@@ -1,11 +0,3 @@

# `common_library`
# @matchlighter/common_library
> TODO: description
## Usage
```
const commonLibrary = require('common_library');
// TODO: DEMONSTRATE API
```
A set of shared Functions, Helpers, Patterns & Utilities for Apps and Libraries.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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