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

@solid-primitives/utils

Package Overview
Dependencies
Maintainers
2
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-primitives/utils - npm Package Compare versions

Comparing version 0.0.200 to 0.0.250

dist/index.cjs

37

dist/index.d.ts

@@ -1,20 +0,23 @@

import type { Accessor } from "solid-js";
export declare type Fn<R = void> = () => R;
export declare type Many<T> = T | T[];
import { Accessor } from 'solid-js';
declare type Fn<R = void> = () => R;
declare type Many<T> = T | T[];
/**
* Infers the element type of an array
*/
export declare type ItemsOf<T> = T extends (infer E)[] ? E : never;
export declare type MaybeAccessor<T> = T | Accessor<T>;
export declare type MaybeAccessorValue<T extends MaybeAccessor<any>> = T extends Fn ? ReturnType<T> : T;
export declare const isClient: boolean;
export declare const access: <T extends unknown>(v: T) => MaybeAccessorValue<T>;
export declare const accessAsArray: <T extends unknown, V = MaybeAccessorValue<T>>(value: T) => V extends any[] ? V : V[];
export declare const withAccess: <T, A extends MaybeAccessor<T>, V = MaybeAccessorValue<A>>(value: A, fn: (value: NonNullable<V>) => void) => void;
export declare const promiseTimeout: (ms: number, throwOnTimeout?: boolean, reason?: string) => Promise<void>;
export declare const objectOmit: <T extends Object, K extends (keyof T)[]>(object: T, ...keys: K) => Omit<T, ItemsOf<K>>;
export declare const stringConcat: (...a: MaybeAccessor<any>[]) => string;
export declare const concat: <A extends any[], V = MaybeAccessorValue<ItemsOf<A>>>(...a: A) => (V extends any[] ? ItemsOf<V> : V)[];
export declare const toFloat: (string: MaybeAccessor<string>) => number;
export declare const toInt: (string: MaybeAccessor<string>, radix?: number | undefined) => number;
export declare const toArray: <A extends any[]>(...a: A) => MaybeAccessorValue<ItemsOf<A>>[];
declare type ItemsOf<T> = T extends (infer E)[] ? E : never;
declare type MaybeAccessor<T> = T | Accessor<T>;
declare type MaybeAccessorValue<T extends MaybeAccessor<any>> = T extends Fn ? ReturnType<T> : T;
declare const isClient: boolean;
declare const access: <T extends unknown>(v: T) => MaybeAccessorValue<T>;
declare const accessAsArray: <T extends unknown, V = MaybeAccessorValue<T>>(value: T) => V extends any[] ? V : V[];
declare const withAccess: <T, A extends MaybeAccessor<T>, V = MaybeAccessorValue<A>>(value: A, fn: (value: NonNullable<V>) => void) => void;
declare const promiseTimeout: (ms: number, throwOnTimeout?: boolean, reason?: string) => Promise<void>;
declare const objectOmit: <T extends Object, K extends (keyof T)[]>(object: T, ...keys: K) => Omit<T, ItemsOf<K>>;
declare const stringConcat: (...a: MaybeAccessor<any>[]) => string;
declare const concat: <A extends any[], V = MaybeAccessorValue<ItemsOf<A>>>(...a: A) => (V extends any[] ? ItemsOf<V> : V)[];
declare const toFloat: (string: MaybeAccessor<string>) => number;
declare const toInt: (string: MaybeAccessor<string>, radix?: number | undefined) => number;
declare const toArray: <A extends any[]>(...a: A) => MaybeAccessorValue<ItemsOf<A>>[];
export { Fn, ItemsOf, Many, MaybeAccessor, MaybeAccessorValue, access, accessAsArray, concat, isClient, objectOmit, promiseTimeout, stringConcat, toArray, toFloat, toInt, withAccess };

@@ -1,30 +0,41 @@

export const isClient = typeof window !== "undefined";
export const access = (v) => typeof v === "function" ? v() : v;
export const accessAsArray = (value) => {
const _value = access(value);
return Array.isArray(_value) ? _value : [_value];
// src/index.ts
var isClient = typeof window !== "undefined";
var access = (v) => typeof v === "function" ? v() : v;
var accessAsArray = (value) => {
const _value = access(value);
return Array.isArray(_value) ? _value : [_value];
};
export const withAccess = (value, fn) => {
const _value = access(value);
if (typeof _value !== "undefined" && _value !== null)
fn(_value);
var withAccess = (value, fn) => {
const _value = access(value);
if (typeof _value !== "undefined" && _value !== null)
fn(_value);
};
export const promiseTimeout = (ms, throwOnTimeout = false, reason = "Timeout") => new Promise((resolve, reject) => throwOnTimeout ? setTimeout(() => reject(reason), ms) : setTimeout(resolve, ms));
export const objectOmit = (object, ...keys) => {
const copy = Object.assign({}, object);
for (const key of keys) {
delete copy[key];
}
return copy;
var promiseTimeout = (ms, throwOnTimeout = false, reason = "Timeout") => new Promise((resolve, reject) => throwOnTimeout ? setTimeout(() => reject(reason), ms) : setTimeout(resolve, ms));
var objectOmit = (object, ...keys) => {
const copy = Object.assign({}, object);
for (const key of keys) {
delete copy[key];
}
return copy;
};
//
// SIGNAL BUILDERS:
//
export const stringConcat = (...a) => a.reduce((t, c) => t + access(c), "");
export const concat = (...a) => a.reduce((t, c) => {
const v = access(c);
return Array.isArray(v) ? [...t, ...v] : [...t, v];
var stringConcat = (...a) => a.reduce((t, c) => t + access(c), "");
var concat = (...a) => a.reduce((t, c) => {
const v = access(c);
return Array.isArray(v) ? [...t, ...v] : [...t, v];
}, []);
export const toFloat = (string) => Number.parseFloat(access(string));
export const toInt = (string, radix) => Number.parseInt(access(string), radix);
export const toArray = (...a) => a.map(v => access(v));
var toFloat = (string) => Number.parseFloat(access(string));
var toInt = (string, radix) => Number.parseInt(access(string), radix);
var toArray = (...a) => a.map((v) => access(v));
export {
access,
accessAsArray,
concat,
isClient,
objectOmit,
promiseTimeout,
stringConcat,
toArray,
toFloat,
toInt,
withAccess
};
{
"name": "@solid-primitives/utils",
"version": "0.0.200",
"version": "0.0.250",
"description": "A bunch of reactive utility types and functions, for building primitives with Solid.js",
"author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>",
"license": "MIT",
"homepage": "https://github.com/davedbase/solid-primitives/utils#readme",
"homepage": "https://github.com/davedbase/solid-primitives/tree/main/packages/utils#readme",
"repository": {

@@ -13,3 +13,5 @@ "type": "git",

"private": false,
"main": "dist/cjs/index.cjs",
"sideEffects": false,
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.js",

@@ -20,13 +22,4 @@ "types": "dist/index.d.ts",

],
"exports": {
"require": "./dist/cjs/index.cjs",
"import": "./dist/index.js",
"default": "./dist/index.js"
},
"sideEffects": false,
"scripts": {
"prebuild": "npm run clean",
"clean": "rimraf dist/",
"build": "tsc && tsc -p ./tsconfig-cjs.json",
"test": "uvu -r solid-register"
"build": "tsup"
},

@@ -42,6 +35,5 @@ "keywords": [

"prettier": "^2.4.1",
"rimraf": "^3.0.2",
"solid-register": "^0.0.18",
"tslib": "^2.3.1",
"typescript": "^4.5.2",
"tsup": "^5.10.1",
"uvu": "^0.5.2"

@@ -48,0 +40,0 @@ },

# @solid-primitives/utils
Solid Primitives Utilities is a support and helper package for a number of primitives in our library. Please free to augment or centralise useful utilities and methods in this package for sharing.
## Changelog
<details>
<summary><b>Expand Changelog</b></summary>
0.0.100
First commit of the timer primitive.
0.0.250
Republished version with better ESM support and build tooling.
</details>
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