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

solid-js

Package Overview
Dependencies
Maintainers
1
Versions
463
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

solid-js - npm Package Compare versions

Comparing version 0.0.15 to 0.0.16

4

dist/solid.js

@@ -110,3 +110,3 @@ import S from 's-js';

const selection = arguments[i];
if (typeof selection === 'function' || 'then' in selection || 'subscribe' in selection) {
if (typeof selection === 'function') {
S.makeComputationNode(mapFn1(selection));

@@ -573,3 +573,3 @@ continue;

function pipe(input, ...fns) {
compose(...fns)(input);
return compose(...fns)(input);
}

@@ -576,0 +576,0 @@

# Operators
Operators in Solid are functionally composable or pipeable and constructed using currying. They all take their arguments and return a function that takes a function, Observable, or Promise. In so when using Solid you may find you aren't explicitly using the Signal factory as much as you might expect.
Operators in Solid are functionally composable or pipeable and constructed using currying. Operators are typically factories that return a function that takes an input function expression and return a new function expression.
```js
let transform = operator(...args);
let output = transform(input);
let value = output();
```
These output functions are then consumed by Selectors or bindings which create the dependency tracking. More concretely:
```js
import { State, map } from 'solid-js'

@@ -11,7 +19,9 @@

// single expression
upperName$ = map((name) => name.toUpperCase())(() => state.name)
upperName = map((name) => name.toUpperCase())(() => state.name)
// in steps
reverseName = map((name) => name.reverse())
reverseUpperName$ = reverseName(upperName$)
reverseUpperName = reverseName(upperName)
state.select({ upperName, reverseUpperName });
```

@@ -26,4 +36,4 @@

### from(fn | observable | promise, seed)
No-op for fn's, but ensures observables/promises are made into a Signal.
### from(observable | promise, seed)
Makes promises/observables trackable by Solid.

@@ -35,6 +45,6 @@ Current operators:

### map((value) => ....)
### map(value => ....)
Maps a value to a new value.
### memo((item) => ....)
### memo(item => ....)
A super mapper for rendering, memo is a memoized map that returns previously mapped value if input value is the same. It automatically splits across arrays and clears on falsey values.

@@ -45,3 +55,3 @@

To write your own pipeable operator involves creating a function that returns a function that takes a thunk and returns a new thunk. Generally it looks like this:
Given all operators are composable and don't involve hoisting writing your own operators is trivial. Generally it looks like this:

@@ -65,4 +75,4 @@ ```js

derived: pipe(
() => state.data
map(i => i)
() => state.data,
map(i => i),
someOperator(...someArguments)

@@ -69,0 +79,0 @@ )

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

const selection = arguments[i];
if (typeof selection === 'function' || 'then' in selection || 'subscribe' in selection) {
if (typeof selection === 'function') {
S.makeComputationNode(mapFn1(selection));

@@ -579,3 +579,3 @@ continue;

function pipe(input, ...fns) {
compose(...fns)(input);
return compose(...fns)(input);
}

@@ -582,0 +582,0 @@

{
"name": "solid-js",
"description": "A declarative JavaScript library for building user interfaces.",
"version": "0.0.15",
"version": "0.0.16",
"author": "Ryan Carniato",

@@ -19,3 +19,3 @@ "license": "MIT",

"peerDependencies": {
"babel-plugin-jsx-dom-expressions": "~0.0.28",
"babel-plugin-jsx-dom-expressions": "~0.0.29",
"s-js": "~0.4.9"

@@ -22,0 +22,0 @@ },

@@ -47,3 +47,8 @@ # Solid.js

```
## Installation
```sh
> npm install solid-js s-js babel-plugin-jsx-dom-expressions
```
## Solid State

@@ -50,0 +55,0 @@

const S = require('s-js');
const { from } = require('../lib/solid');
const { from, pipe, map } = require('../lib/solid');
const Observable = require('zen-observable');
describe('Signal factory', () => {
describe('from operator', () => {

@@ -61,1 +61,22 @@ test('Signal passthrough', () => {

});
describe('pipe operator', () => {
test('Signal passthrough', () => {
S.root(() => {
var data = S.data(5),
out = pipe(data);
expect(out).toBe(data);
});
});
test('pipe map', () => {
S.root(() => {
var data = S.data(5),
out = pipe(data, map(i => i * 2));
expect(out()).toBe(data() * 2);
});
});
});
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