Skip to content

Commit

Permalink
Rename childAt() to just at()
Browse files Browse the repository at this point in the history
This feels simpler, and also in keeping with the nomenclature of the
`At()` lens.
  • Loading branch information
cowboyd authored and taras committed May 4, 2019
1 parent 67b7b70 commit 23edff1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export const Context = type(class {
return 'Context';
}

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

export const { childAt } = Context.prototype;
export const { at } = Context.prototype;
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { compose, view, over, set, Lens, transparent, At, Path } from "./lens";
export { childAt, Context } from "./context";
export { at, Context } from "./context";
5 changes: 2 additions & 3 deletions src/lens.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Functor, map, Semigroup } from 'funcadelic';

import { childAt } from './context';
import { at } from './context';

class Box {
static get of() {
Expand Down Expand Up @@ -61,7 +60,7 @@ export function Lens(get, set) {
export const transparent = Lens(x => x, y => y);

export function At(property, container) {
let get = context => context != null ? childAt(property, context) : undefined;
let get = context => context != null ? at(property, context) : undefined;
let set = (part, whole) => {
let context = whole == null ? (Array.isArray(container) ? [] : {}) : whole;
if (part === context[property]) {
Expand Down

0 comments on commit 23edff1

Please sign in to comment.