New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hydro-js

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hydro-js - npm Package Compare versions

Comparing version 1.5.4 to 1.5.5

8

CHANGELOG.md
# Changelog
## 1.5.5- 2021-01-02
- Improve TypeScript types of $ and $$
## 1.5.4- 2021-12-30
- Perf Tweak in view function
## 1.5.3- 2021-12-30

@@ -4,0 +12,0 @@

26

dist/library.d.ts

@@ -68,12 +68,18 @@ declare global {

declare const hydro: hydroObject;
declare const $: {
<K extends keyof HTMLElementTagNameMap>(selectors: K): HTMLElementTagNameMap[K] | null;
<K_1 extends keyof SVGElementTagNameMap>(selectors: K_1): SVGElementTagNameMap[K_1] | null;
<E extends Element = Element>(selectors: string): E | null;
};
declare const $$: {
<K extends keyof HTMLElementTagNameMap>(selectors: K): NodeListOf<HTMLElementTagNameMap[K]>;
<K_1 extends keyof SVGElementTagNameMap>(selectors: K_1): NodeListOf<SVGElementTagNameMap[K_1]>;
<E extends Element = Element>(selectors: string): NodeListOf<E>;
};
declare const $: <T extends string>(query: T) => MatchEachElement<GetEachElementName<Split<T, ",">, []>, null>;
declare const $$: <T extends string>(query: T) => [] | NonNullable<MatchEachElement<GetEachElementName<Split<T, ",">, []>, null>>[];
declare type Split<S extends string, D extends string> = S extends `${infer T}${D}${infer U}` ? [T, ...Split<U, D>] : [S];
declare type TakeLast<V> = V extends [] ? never : V extends [string] ? V[0] : V extends [string, ...infer R] ? TakeLast<R> : never;
declare type TrimLeft<V extends string> = V extends ` ${infer R}` ? TrimLeft<R> : V;
declare type TrimRight<V extends string> = V extends `${infer R} ` ? TrimRight<R> : V;
declare type Trim<V extends string> = TrimLeft<TrimRight<V>>;
declare type StripModifier<V extends string, M extends string> = V extends `${infer L}${M}${infer A}` ? L : V;
declare type StripModifiers<V extends string> = StripModifier<StripModifier<StripModifier<StripModifier<V, ".">, "#">, "[">, ":">;
declare type TakeLastAfterToken<V extends string, T extends string> = StripModifiers<TakeLast<Split<Trim<V>, T>>>;
declare type GetLastElementName<V extends string> = TakeLastAfterToken<TakeLastAfterToken<V, " ">, ">">;
declare type GetEachElementName<V, L extends string[] = []> = V extends [] ? L : V extends [string] ? [...L, GetLastElementName<V[0]>] : V extends [string, ...infer R] ? GetEachElementName<R, [...L, GetLastElementName<V[0]>]> : [];
declare type GetElementNames<V extends string> = GetEachElementName<Split<V, ",">>;
declare type ElementByName<V extends string> = V extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[V] : V extends keyof SVGElementTagNameMap ? SVGElementTagNameMap[V] : Element;
declare type MatchEachElement<V, L extends Element | null = null> = V extends [] ? L : V extends [string] ? L | ElementByName<V[0]> : V extends [string, ...infer R] ? MatchEachElement<R, L | ElementByName<V[0]>> : L;
declare type QueryResult<T extends string> = MatchEachElement<GetElementNames<T>>;
declare const internals: {

@@ -80,0 +86,0 @@ compare: typeof compare;

{
"name": "hydro-js",
"version": "1.5.4",
"version": "1.5.5",
"description": "A lightweight reactive library",

@@ -5,0 +5,0 @@ "type": "module",

@@ -1702,5 +1702,63 @@ declare global {

const hydro = generateProxy();
const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document);
const $ = document.querySelector.bind(document) as <T extends string>(
query: T
) => QueryResult<T>;
const $$ = document.querySelectorAll.bind(document) as unknown as <
T extends string
>(
query: T
) => Array<NonNullable<QueryResult<T>>> | [];
// Credit to https://twitter.com/MikeRyanDev/status/1308472279010025477
type Split<
S extends string,
D extends string
> = S extends `${infer T}${D}${infer U}` ? [T, ...Split<U, D>] : [S];
type TakeLast<V> = V extends []
? never
: V extends [string]
? V[0]
: V extends [string, ...infer R]
? TakeLast<R>
: never;
type TrimLeft<V extends string> = V extends ` ${infer R}` ? TrimLeft<R> : V;
type TrimRight<V extends string> = V extends `${infer R} ` ? TrimRight<R> : V;
type Trim<V extends string> = TrimLeft<TrimRight<V>>;
type StripModifier<
V extends string,
M extends string
> = V extends `${infer L}${M}${infer A}` ? L : V;
type StripModifiers<V extends string> = StripModifier<
StripModifier<StripModifier<StripModifier<V, ".">, "#">, "[">,
":"
>;
type TakeLastAfterToken<V extends string, T extends string> = StripModifiers<
TakeLast<Split<Trim<V>, T>>
>;
type GetLastElementName<V extends string> = TakeLastAfterToken<
TakeLastAfterToken<V, " ">,
">"
>;
type GetEachElementName<V, L extends string[] = []> = V extends []
? L
: V extends [string]
? [...L, GetLastElementName<V[0]>]
: V extends [string, ...infer R]
? GetEachElementName<R, [...L, GetLastElementName<V[0]>]>
: [];
type GetElementNames<V extends string> = GetEachElementName<Split<V, ",">>;
type ElementByName<V extends string> = V extends keyof HTMLElementTagNameMap
? HTMLElementTagNameMap[V]
: V extends keyof SVGElementTagNameMap
? SVGElementTagNameMap[V]
: Element;
type MatchEachElement<V, L extends Element | null = null> = V extends []
? L
: V extends [string]
? L | ElementByName<V[0]>
: V extends [string, ...infer R]
? MatchEachElement<R, L | ElementByName<V[0]>>
: L;
type QueryResult<T extends string> = MatchEachElement<GetElementNames<T>>;
const internals = {

@@ -1707,0 +1765,0 @@ compare,

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