Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"rxjs": "^6.2.1"
},
"dependencies": {
"@microstates/lens": "1.0.0-beta.2",
"funcadelic": "^0.5.0",
"symbol-observable": "^1.2.0"
},
Expand Down
3 changes: 2 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const replace = require('rollup-plugin-replace');

const external = [
"funcadelic",
"symbol-observable"
"symbol-observable",
"@microstates/lens"
];

const babelPlugin = babel({
Expand Down
83 changes: 0 additions & 83 deletions src/lens.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/meta.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { At, compose, transparent, over, view } from './lens';
import { At, compose, transparent, over, view } from '@microstates/lens';

export class Meta {
static symbol = Symbol('Meta');
Expand Down
2 changes: 1 addition & 1 deletion src/microstates.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { append, stable, map } from 'funcadelic';
import { set } from './lens';
import { set } from '@microstates/lens';
import { Meta, mount, metaOf, valueOf, sourceOf } from './meta';
import { methodsOf } from './reflection';
import dsl from './dsl';
Expand Down
2 changes: 1 addition & 1 deletion src/pathmap.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { view, Path } from '@microstates/lens';
import { methodsOf } from './reflection';
import { create } from './microstates';
import { view, Path } from './lens';
import { valueOf, Meta } from './meta';
import { defineChildren } from './tree';
import { stable } from 'funcadelic';
Expand Down
2 changes: 1 addition & 1 deletion src/storage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { view, set, Path } from './lens';
import { view, set, Path } from '@microstates/lens';

export default class Storage {
constructor(value, observe = x => x) {
Expand Down
10 changes: 1 addition & 9 deletions src/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ import CachedProperty from './cached-property';
export const Tree = type(class {
static name = 'Tree';

childAt(key, parent) {
if (parent[Tree.symbol]) {
return this(parent).childAt(key, parent);
} else {
return parent[key];
}
}

defineChildren(fn, parent) {
if (parent[Tree.symbol]) {
return this(parent).defineChildren(fn, parent);
Expand All @@ -24,4 +16,4 @@ export const Tree = type(class {
}
});

export const { childAt, defineChildren } = Tree.prototype;
export const { defineChildren } = Tree.prototype;
14 changes: 8 additions & 6 deletions src/types/array.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { At, set } from '../lens';
import { at, At, set, Context } from '@microstates/lens';
import { mount, valueOf } from '../meta';
import { create } from '../microstates';
import parameterized from '../parameterized';
import { Tree, childAt } from '../tree';
import { Tree } from '../tree';

export default parameterized(T => class ArrayType {
static T = T;
Expand Down Expand Up @@ -88,7 +88,7 @@ export default parameterized(T => class ArrayType {
get done() { return next.done; },
get value() {
if (!next.done) {
return childAt(index, array);
return at(index, array);
} else {
return undefined;
}
Expand All @@ -100,16 +100,18 @@ export default parameterized(T => class ArrayType {

static initialize() {

Tree.instance(this, {
childAt(key, array) {
Context.instance(this, {
at(key, array) {
if (typeof key === 'number') {
let value = valueOf(array)[key];
return mount(array, create(T, value), key);
} else {
return array[key];
}
},
}
});

Tree.instance(this, {
defineChildren(fn, array) {
let generate = array[Symbol.iterator];
return Object.defineProperty(array, Symbol.iterator, {
Expand Down
16 changes: 10 additions & 6 deletions src/types/object.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { append, filter, map } from 'funcadelic';
import { at, Context } from '@microstates/lens';
import { reduce, query } from '../query';
import parameterized from '../parameterized';
import { valueOf, mount } from '../meta';
import { create } from '../microstates';
import { Tree, childAt } from '../tree';

import { Tree } from '../tree';

export default parameterized(T => class ObjectType {
static T = T;
Expand Down Expand Up @@ -59,7 +59,7 @@ export default parameterized(T => class ObjectType {
get done() { return next.done; },
get value() {
if (!next.done) {
return new Entry(next.value, childAt(next.value, object));
return new Entry(next.value, at(next.value, object));
} else {
return undefined;
}
Expand All @@ -70,15 +70,19 @@ export default parameterized(T => class ObjectType {
}

static initialize() {
Tree.instance(this, {
childAt(key, object) {

Context.instance(this, {
at(key, object) {
if (typeof key !== 'string') {
return object[key];
} else {
let value = valueOf(object)[key];
return mount(object, create(T, value), key);
}
},
}
});

Tree.instance(this, {
defineChildren(fn, object) {
let generate = object[Symbol.iterator];
return Object.defineProperty(object, Symbol.iterator, {
Expand Down
25 changes: 0 additions & 25 deletions tests/lens.test.js

This file was deleted.

9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,13 @@
"@types/istanbul-lib-coverage" "^1.1.0"
"@types/yargs" "^12.0.9"

"@microstates/lens@1.0.0-beta.2":
version "1.0.0-beta.2"
resolved "https://registry.yarnpkg.com/@microstates/lens/-/lens-1.0.0-beta.2.tgz#b43badbe038a90f95f13f4ae57a34fddd380c356"
integrity sha512-WrPBgPut3h8c7/Yl1tIaA8Fw4TV80mx3EXJGvumBhx15GE+z31HB+31loz9+I4dbGq6xC4Xi7rhMXdiBqRK6Ug==
dependencies:
funcadelic "^0.5.7"

"@types/estree@0.0.39":
version "0.0.39"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
Expand Down Expand Up @@ -1814,7 +1821,7 @@ fs.realpath@^1.0.0:
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=

funcadelic@^0.5.0:
funcadelic@^0.5.0, funcadelic@^0.5.7:
version "0.5.7"
resolved "https://registry.yarnpkg.com/funcadelic/-/funcadelic-0.5.7.tgz#e76f6a9028985531924c1159dc1c930f5b00acb2"
integrity sha512-kwKSJVAd2FNFmBgku81FC6VJCQdgcT/gtwG9z7H7FxL4NlDKsbdGqLwtjbDlYgR77t+NuT8phBLkmLSKsg1J5w==
Expand Down