123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 |
- // Jest Snapshot v1, https://goo.gl/fbAQLP
- exports[`functional_compose.js 1`] = `
- compose(
- sortBy(x => x),
- flatten,
- map(x => [x, x*2])
- );
- somelib.compose(
- sortBy(x => x),
- flatten,
- map(x => [x, x*2])
- );
- composeFlipped(
- sortBy(x => x),
- flatten,
- map(x => [x, x*2])
- );
- somelib.composeFlipped(
- sortBy(x => x),
- flatten,
- map(x => [x, x*2])
- );
- // no regression (#4602)
- const hasValue = hasOwnProperty(a, b);
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- compose(
- sortBy(x => x),
- flatten,
- map(x => [x, x * 2])
- );
- somelib.compose(
- sortBy(x => x),
- flatten,
- map(x => [x, x * 2])
- );
- composeFlipped(
- sortBy(x => x),
- flatten,
- map(x => [x, x * 2])
- );
- somelib.composeFlipped(
- sortBy(x => x),
- flatten,
- map(x => [x, x * 2])
- );
- // no regression (#4602)
- const hasValue = hasOwnProperty(a, b);
- `;
- exports[`lodash_flow.js 1`] = `
- import { flow } from "lodash";
- const foo = flow(
- x => x + 1,
- x => x * 3,
- x => x - 6,
- );
- foo(6);
- import * as _ from "lodash";
- const foo = _.flow(
- x => x + 1,
- x => x * 3,
- x => x - 6,
- );
- foo(6);
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- import { flow } from "lodash";
- const foo = flow(
- x => x + 1,
- x => x * 3,
- x => x - 6
- );
- foo(6);
- import * as _ from "lodash";
- const foo = _.flow(
- x => x + 1,
- x => x * 3,
- x => x - 6
- );
- foo(6);
- `;
- exports[`lodash_flow_right.js 1`] = `
- import { flowRight } from "lodash";
- const foo = flowRight(
- x => x + 1,
- x => x * 3,
- x => x - 6,
- );
- foo(6);
- import * as _ from "lodash";
- const foo = _.flowRight(
- x => x + 1,
- x => x * 3,
- x => x - 6,
- );
- foo(6);
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- import { flowRight } from "lodash";
- const foo = flowRight(
- x => x + 1,
- x => x * 3,
- x => x - 6
- );
- foo(6);
- import * as _ from "lodash";
- const foo = _.flowRight(
- x => x + 1,
- x => x * 3,
- x => x - 6
- );
- foo(6);
- `;
- exports[`ramda_compose.js 1`] = `
- var classyGreeting = (firstName, lastName) =>
- "The name's " + lastName + ", " + firstName + " " + lastName;
- var yellGreeting = R.compose(R.toUpper, classyGreeting);
- yellGreeting("James", "Bond"); //=> "THE NAME'S BOND, JAMES BOND"
- R.compose(Math.abs, R.add(1), R.multiply(2))(-4); //=> 7
- // get :: String -> Object -> Maybe *
- var get = R.curry((propName, obj) => Maybe(obj[propName]));
- // getStateCode :: Maybe String -> Maybe String
- var getStateCode = R.composeK(
- R.compose(Maybe.of, R.toUpper),
- get("state"),
- get("address"),
- get("user")
- );
- getStateCode({ user: { address: { state: "ny" } } }); //=> Maybe.Just("NY")
- getStateCode({}); //=> Maybe.Nothing()
- var db = {
- users: {
- JOE: {
- name: "Joe",
- followers: ["STEVE", "SUZY"]
- }
- }
- };
- // We'll pretend to do a db lookup which returns a promise
- var lookupUser = userId => Promise.resolve(db.users[userId]);
- var lookupFollowers = user => Promise.resolve(user.followers);
- lookupUser("JOE").then(lookupFollowers);
- // followersForUser :: String -> Promise [UserId]
- var followersForUser = R.composeP(lookupFollowers, lookupUser);
- followersForUser("JOE").then(followers => console.log("Followers:", followers));
- // Followers: ["STEVE","SUZY"]
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- var classyGreeting = (firstName, lastName) =>
- "The name's " + lastName + ", " + firstName + " " + lastName;
- var yellGreeting = R.compose(
- R.toUpper,
- classyGreeting
- );
- yellGreeting("James", "Bond"); //=> "THE NAME'S BOND, JAMES BOND"
- R.compose(
- Math.abs,
- R.add(1),
- R.multiply(2)
- )(-4); //=> 7
- // get :: String -> Object -> Maybe *
- var get = R.curry((propName, obj) => Maybe(obj[propName]));
- // getStateCode :: Maybe String -> Maybe String
- var getStateCode = R.composeK(
- R.compose(
- Maybe.of,
- R.toUpper
- ),
- get("state"),
- get("address"),
- get("user")
- );
- getStateCode({ user: { address: { state: "ny" } } }); //=> Maybe.Just("NY")
- getStateCode({}); //=> Maybe.Nothing()
- var db = {
- users: {
- JOE: {
- name: "Joe",
- followers: ["STEVE", "SUZY"]
- }
- }
- };
- // We'll pretend to do a db lookup which returns a promise
- var lookupUser = userId => Promise.resolve(db.users[userId]);
- var lookupFollowers = user => Promise.resolve(user.followers);
- lookupUser("JOE").then(lookupFollowers);
- // followersForUser :: String -> Promise [UserId]
- var followersForUser = R.composeP(
- lookupFollowers,
- lookupUser
- );
- followersForUser("JOE").then(followers => console.log("Followers:", followers));
- // Followers: ["STEVE","SUZY"]
- `;
- exports[`ramda_pipe.js 1`] = `
- var f = R.pipe(Math.pow, R.negate, R.inc);
- f(3, 4); // -(3^4) + 1
- // parseJson :: String -> Maybe *
- // get :: String -> Object -> Maybe *
- // getStateCode :: Maybe String -> Maybe String
- var getStateCode = R.pipeK(
- parseJson,
- get("user"),
- get("address"),
- get("state"),
- R.compose(Maybe.of, R.toUpper)
- );
- getStateCode('{"user":{"address":{"state":"ny"}}}');
- //=> Just('NY')
- getStateCode("[Invalid JSON]");
- //=> Nothing()
- // followersForUser :: String -> Promise [User]
- var followersForUser = R.pipeP(db.getUserById, db.getFollowers);
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- var f = R.pipe(
- Math.pow,
- R.negate,
- R.inc
- );
- f(3, 4); // -(3^4) + 1
- // parseJson :: String -> Maybe *
- // get :: String -> Object -> Maybe *
- // getStateCode :: Maybe String -> Maybe String
- var getStateCode = R.pipeK(
- parseJson,
- get("user"),
- get("address"),
- get("state"),
- R.compose(
- Maybe.of,
- R.toUpper
- )
- );
- getStateCode('{"user":{"address":{"state":"ny"}}}');
- //=> Just('NY')
- getStateCode("[Invalid JSON]");
- //=> Nothing()
- // followersForUser :: String -> Promise [User]
- var followersForUser = R.pipeP(
- db.getUserById,
- db.getFollowers
- );
- `;
- exports[`redux_compose.js 1`] = `
- import { createStore, applyMiddleware, compose } from 'redux';
- import thunk from 'redux-thunk';
- import DevTools from './containers/DevTools';
- import reducer from '../reducers';
- const store = createStore(
- reducer,
- compose(
- applyMiddleware(thunk),
- DevTools.instrument()
- )
- )
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- import { createStore, applyMiddleware, compose } from "redux";
- import thunk from "redux-thunk";
- import DevTools from "./containers/DevTools";
- import reducer from "../reducers";
- const store = createStore(
- reducer,
- compose(
- applyMiddleware(thunk),
- DevTools.instrument()
- )
- );
- `;
- exports[`redux_connect.js 1`] = `
- const ArtistInput = connect(mapStateToProps, mapDispatchToProps, mergeProps)(Component);
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- const ArtistInput = connect(
- mapStateToProps,
- mapDispatchToProps,
- mergeProps
- )(Component);
- `;
- exports[`rxjs_pipe.js 1`] = `
- import { range } from 'rxjs/observable/range';
- import { map, filter, scan } from 'rxjs/operators';
- const source$ = range(0, 10);
- source$.pipe(
- filter(x => x % 2 === 0),
- map(x => x + x),
- scan((acc, x) => acc + x, 0)
- )
- .subscribe(x => console.log(x))
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- import { range } from "rxjs/observable/range";
- import { map, filter, scan } from "rxjs/operators";
- const source$ = range(0, 10);
- source$
- .pipe(
- filter(x => x % 2 === 0),
- map(x => x + x),
- scan((acc, x) => acc + x, 0)
- )
- .subscribe(x => console.log(x));
- `;
|