« get me outta code hell

data: composite "to" -> "into" - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-09-07 11:37:58 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-09-07 11:37:58 -0300
commit4541b2aa65a2f5ccfb7f9a13d5605311fd8ef801 (patch)
treeeee762c3f5ef98e5b877cd8c47ade686d32b2b70
parentba04498715423c165cdb254676cc211c48b7c8ab (diff)
data: composite "to" -> "into"
-rw-r--r--src/data/things/composite.js28
-rw-r--r--src/data/things/thing.js34
-rw-r--r--src/data/things/track.js62
3 files changed, 62 insertions, 62 deletions
diff --git a/src/data/things/composite.js b/src/data/things/composite.js
index f59e7d75..976f7804 100644
--- a/src/data/things/composite.js
+++ b/src/data/things/composite.js
@@ -106,7 +106,7 @@ import {
 //
 //   withResolvedContribs = ({
 //     from: contribsByRefDependency,
-//     to: outputDependency,
+//     into: outputDependency,
 //   }) => ({
 //     flags: {expose: true, compose: true},
 //     expose: {
@@ -132,7 +132,7 @@ import {
 //
 //       withResolvedContribs({
 //         from: 'coverArtistContribsByRef',
-//         to: '#coverArtistContribs',
+//         into: '#coverArtistContribs',
 //       }),
 //
 //       {
@@ -171,7 +171,7 @@ import {
 //
 //   withResolvedContribs = ({
 //     from: contribsByRefDependency,
-//     to: outputDependency,
+//     into: outputDependency,
 //   }) => ({
 //     flags: {expose: true, compose: true},
 //     expose: {
@@ -199,11 +199,11 @@ import {
 //     expose: {
 //       dependencies: ['artistData'],
 //       mapDependencies: {from},
-//       mapContinuation: {to},
+//       mapContinuation: {into},
 //       compute({artistData, from: contribsByRef}, continuation) {
 //         if (!artistData) return null;
 //         return continuation({
-//           to: (..resolve contributions one way or another..),
+//           into: (..resolve contributions one way or another..),
 //         });
 //       },
 //     },
@@ -505,8 +505,8 @@ export function compositeFrom(firstArg, secondArg) {
         : {});
 
     if (mapDependencies) {
-      for (const [to, from] of Object.entries(mapDependencies)) {
-        filteredDependencies[to] = availableDependencies[from] ?? null;
+      for (const [into, from] of Object.entries(mapDependencies)) {
+        filteredDependencies[into] = availableDependencies[from] ?? null;
       }
     }
 
@@ -524,8 +524,8 @@ export function compositeFrom(firstArg, secondArg) {
 
     const assignDependencies = {};
 
-    for (const [from, to] of Object.entries(mapContinuation)) {
-      assignDependencies[to] = continuationAssignment[from] ?? null;
+    for (const [from, into] of Object.entries(mapContinuation)) {
+      assignDependencies[into] = continuationAssignment[from] ?? null;
     }
 
     return assignDependencies;
@@ -861,7 +861,7 @@ export function withResultOfAvailabilityCheck({
   fromUpdateValue,
   fromDependency,
   mode = 'null',
-  to = '#availability',
+  into = '#availability',
 }) {
   if (!['null', 'empty', 'falsy'].includes(mode)) {
     throw new TypeError(`Expected mode to be null, empty, or falsy`);
@@ -890,10 +890,10 @@ export function withResultOfAvailabilityCheck({
       flags: {expose: true, compose: true},
       expose: {
         mapDependencies: {from: fromDependency},
-        mapContinuation: {to},
+        mapContinuation: {into},
         options: {mode},
         compute: ({from, '#options': {mode}}, continuation) =>
-          continuation({to: checkAvailability(from, mode)}),
+          continuation({into: checkAvailability(from, mode)}),
       },
     };
   } else {
@@ -901,10 +901,10 @@ export function withResultOfAvailabilityCheck({
       annotation: `withResultOfAvailabilityCheck.fromUpdateValue`,
       flags: {expose: true, compose: true},
       expose: {
-        mapContinuation: {to},
+        mapContinuation: {into},
         options: {mode},
         transform: (value, {'#options': {mode}}, continuation) =>
-          continuation(value, {to: checkAvailability(value, mode)}),
+          continuation(value, {into: checkAvailability(value, mode)}),
       },
     };
   }
diff --git a/src/data/things/thing.js b/src/data/things/thing.js
index 9b564ee9..16003b00 100644
--- a/src/data/things/thing.js
+++ b/src/data/things/thing.js
@@ -236,7 +236,7 @@ export default class Thing extends CacheableObject {
       return compositeFrom(`Thing.common.dynamicContribs`, [
         withResolvedContribs({
           from: contribsByRefProperty,
-          to: '#contribs',
+          into: '#contribs',
         }),
 
         exposeDependency('#contribs'),
@@ -335,12 +335,12 @@ export default class Thing extends CacheableObject {
 // providing (named by the second argument) the result. "Resolving"
 // means mapping the "who" reference of each contribution to an artist
 // object, and filtering out those whose "who" doesn't match any artist.
-export function withResolvedContribs({from, to}) {
+export function withResolvedContribs({from, into}) {
   return compositeFrom(`withResolvedContribs`, [
     raiseWithoutDependency(from, {
       mode: 'empty',
-      map: {to},
-      raise: {to: []},
+      map: {into},
+      raise: {into: []},
     }),
 
     {
@@ -355,18 +355,18 @@ export function withResolvedContribs({from, to}) {
     withResolvedReferenceList({
       list: '#whoByRef',
       data: 'artistData',
-      to: '#who',
+      into: '#who',
       find: find.artist,
       notFoundMode: 'null',
     }),
 
     {
       dependencies: ['#who', '#what'],
-      mapContinuation: {to},
+      mapContinuation: {into},
       compute({'#who': who, '#what': what}, continuation) {
         filterMultipleArrays(who, what, (who, _what) => who);
         return continuation({
-          to: stitchArrays({who, what}),
+          into: stitchArrays({who, what}),
         });
       },
     },
@@ -383,7 +383,7 @@ export function withResolvedReference({
   ref,
   data,
   find: findFunction,
-  to = '#resolvedReference',
+  into = '#resolvedReference',
   notFoundMode = 'null',
 }) {
   if (!['exit', 'null'].includes(notFoundMode)) {
@@ -391,13 +391,13 @@ export function withResolvedReference({
   }
 
   return compositeFrom(`withResolvedReference`, [
-    raiseWithoutDependency(ref, {map: {to}, raise: {to: null}}),
+    raiseWithoutDependency(ref, {map: {into}, raise: {into: null}}),
     exitWithoutDependency(data),
 
     {
       options: {findFunction, notFoundMode},
       mapDependencies: {ref, data},
-      mapContinuation: {match: to},
+      mapContinuation: {match: into},
 
       compute({ref, data, '#options': {findFunction, notFoundMode}}, continuation) {
         const match = findFunction(ref, data, {mode: 'quiet'});
@@ -421,7 +421,7 @@ export function withResolvedReferenceList({
   list,
   data,
   find: findFunction,
-  to = '#resolvedReferenceList',
+  into = '#resolvedReferenceList',
   notFoundMode = 'filter',
 }) {
   if (!['filter', 'exit', 'null'].includes(notFoundMode)) {
@@ -431,15 +431,15 @@ export function withResolvedReferenceList({
   return compositeFrom(`withResolvedReferenceList`, [
     exitWithoutDependency(data, {value: []}),
     raiseWithoutDependency(list, {
-      map: {to},
-      raise: {to: []},
+      map: {into},
+      raise: {into: []},
       mode: 'empty',
     }),
 
     {
       options: {findFunction, notFoundMode},
       mapDependencies: {list, data},
-      mapContinuation: {matches: to},
+      mapContinuation: {matches: into},
 
       compute({list, data, '#options': {findFunction, notFoundMode}}, continuation) {
         let matches =
@@ -470,7 +470,7 @@ export function withResolvedReferenceList({
 export function withReverseReferenceList({
   data,
   list: refListProperty,
-  to = '#reverseReferenceList',
+  into = '#reverseReferenceList',
 }) {
   return compositeFrom(`Thing.common.reverseReferenceList`, [
     exitWithoutDependency(data, {value: []}),
@@ -478,12 +478,12 @@ export function withReverseReferenceList({
     {
       dependencies: ['this'],
       mapDependencies: {data},
-      mapContinuation: {to},
+      mapContinuation: {into},
       options: {refListProperty},
 
       compute: ({this: thisThing, data, '#options': {refListProperty}}, continuation) =>
         continuation({
-          to: data.filter(thing => thing[refListProperty].includes(thisThing)),
+          into: data.filter(thing => thing[refListProperty].includes(thisThing)),
         }),
     },
   ]);
diff --git a/src/data/things/track.js b/src/data/things/track.js
index 1818e003..1adfe71a 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -216,7 +216,7 @@ export class Track extends Thing {
 
       withResolvedContribs({
         from: 'artistContribsByRef',
-        to: '#artistContribs',
+        into: '#artistContribs',
       }),
 
       {
@@ -250,7 +250,7 @@ export class Track extends Thing {
 
       withResolvedContribs({
         from: 'coverArtistContribsByRef',
-        to: '#coverArtistContribs',
+        into: '#coverArtistContribs',
       }),
 
       {
@@ -363,20 +363,20 @@ function inheritFromOriginalRelease({
 // the output dependency will be null; set {notFoundMode: 'exit'} to early
 // exit instead.
 function withAlbum({
-  to = '#album',
+  into = '#album',
   notFoundMode = 'null',
 } = {}) {
   return compositeFrom(`withAlbum`, [
     withResultOfAvailabilityCheck({
       fromDependency: 'albumData',
       mode: 'empty',
-      to: '#albumDataAvailability',
+      into: '#albumDataAvailability',
     }),
 
     {
       dependencies: ['#albumDataAvailability'],
       options: {notFoundMode},
-      mapContinuation: {to},
+      mapContinuation: {into},
 
       compute: ({
         '#albumDataAvailability': albumDataAvailability,
@@ -386,7 +386,7 @@ function withAlbum({
           ? continuation()
           : (notFoundMode === 'exit'
               ? continuation.exit(null)
-              : continuation.raise({to: null}))),
+              : continuation.raise({into: null}))),
     },
 
     {
@@ -400,17 +400,17 @@ function withAlbum({
     {
       dependencies: ['#album'],
       options: {notFoundMode},
-      mapContinuation: {to},
+      mapContinuation: {into},
 
       compute: ({
         '#album': album,
         '#options': {notFoundMode},
       }, continuation) =>
         (album
-          ? continuation.raise({to: album})
+          ? continuation.raise({into: album})
           : (notFoundMode === 'exit'
               ? continuation.exit(null)
-              : continuation.raise({to: null}))),
+              : continuation.raise({into: null}))),
     },
   ]);
 }
@@ -420,7 +420,7 @@ function withAlbum({
 // isn't available, then by default, the property will be provided as null;
 // set {notFoundMode: 'exit'} to early exit instead.
 function withAlbumProperty(property, {
-  to = '#album.' + property,
+  into = '#album.' + property,
   notFoundMode = 'null',
 } = {}) {
   return compositeFrom(`withAlbumProperty`, [
@@ -429,15 +429,15 @@ function withAlbumProperty(property, {
     {
       dependencies: ['#album'],
       options: {property},
-      mapContinuation: {to},
+      mapContinuation: {into},
 
       compute: ({
         '#album': album,
         '#options': {property},
       }, continuation) =>
         (album
-          ? continuation.raise({to: album[property]})
-          : continuation.raise({to: null})),
+          ? continuation.raise({into: album[property]})
+          : continuation.raise({into: null})),
     },
   ]);
 }
@@ -485,7 +485,7 @@ function withAlbumProperties({
 // If notFoundMode is set to 'exit', this will early exit if the album can't be
 // found or if none of its trackSections includes the track for some reason.
 function withContainingTrackSection({
-  to = '#trackSection',
+  into = '#trackSection',
   notFoundMode = 'null',
 } = {}) {
   if (!['exit', 'null'].includes(notFoundMode)) {
@@ -498,7 +498,7 @@ function withContainingTrackSection({
     {
       dependencies: ['this', '#album.trackSections'],
       options: {notFoundMode},
-      mapContinuation: {to},
+      mapContinuation: {into},
 
       compute({
         this: track,
@@ -506,18 +506,18 @@ function withContainingTrackSection({
         '#options': {notFoundMode},
       }, continuation) {
         if (!trackSections) {
-          return continuation.raise({to: null});
+          return continuation.raise({into: null});
         }
 
         const trackSection =
           trackSections.find(({tracks}) => tracks.includes(track));
 
         if (trackSection) {
-          return continuation.raise({to: trackSection});
+          return continuation.raise({into: trackSection});
         } else if (notFoundMode === 'exit') {
           return continuation.exit(null);
         } else {
-          return continuation.raise({to: null});
+          return continuation.raise({into: null});
         }
       },
     },
@@ -531,14 +531,14 @@ function withContainingTrackSection({
 // specified by reference and that reference doesn't resolve to anything.
 // Outputs to '#originalRelease' by default.
 function withOriginalRelease({
-  to = '#originalRelease',
+  into = '#originalRelease',
   selfIfOriginal = false,
 } = {}) {
   return compositeFrom(`withOriginalRelease`, [
     withResolvedReference({
       ref: 'originalReleaseTrackByRef',
       data: 'trackData',
-      to: '#originalRelease',
+      into: '#originalRelease',
       find: find.track,
       notFoundMode: 'exit',
     }),
@@ -546,14 +546,14 @@ function withOriginalRelease({
     {
       dependencies: ['this', '#originalRelease'],
       options: {selfIfOriginal},
-      mapContinuation: {to},
+      mapContinuation: {into},
       compute: ({
         this: track,
         '#originalRelease': originalRelease,
         '#options': {selfIfOriginal},
       }, continuation) =>
         continuation.raise({
-          to:
+          into:
             (originalRelease ??
               (selfIfOriginal
                 ? track
@@ -566,41 +566,41 @@ function withOriginalRelease({
 // The algorithm for checking if a track has unique cover art is used in a
 // couple places, so it's defined in full as a compositional step.
 function withHasUniqueCoverArt({
-  to = '#hasUniqueCoverArt',
+  into = '#hasUniqueCoverArt',
 } = {}) {
   return compositeFrom(`withHasUniqueCoverArt`, [
     {
       dependencies: ['disableUniqueCoverArt'],
-      mapContinuation: {to},
+      mapContinuation: {into},
       compute: ({disableUniqueCoverArt}, continuation) =>
         (disableUniqueCoverArt
-          ? continuation.raise({to: false})
+          ? continuation.raise({into: false})
           : continuation()),
     },
 
     withResolvedContribs({
       from: 'coverArtistContribsByRef',
-      to: '#coverArtistContribs',
+      into: '#coverArtistContribs',
     }),
 
     {
       dependencies: ['#coverArtistContribs'],
-      mapContinuation: {to},
+      mapContinuation: {into},
       compute: ({'#coverArtistContribs': contribsFromTrack}, continuation) =>
         (empty(contribsFromTrack)
           ? continuation()
-          : continuation.raise({to: true})),
+          : continuation.raise({into: true})),
     },
 
     withAlbumProperty('trackCoverArtistContribs'),
 
     {
       dependencies: ['#album.trackCoverArtistContribs'],
-      mapContinuation: {to},
+      mapContinuation: {into},
       compute: ({'#album.trackCoverArtistContribs': contribsFromAlbum}, continuation) =>
         (empty(contribsFromAlbum)
-          ? continuation.raise({to: false})
-          : continuation.raise({to: true})),
+          ? continuation.raise({into: false})
+          : continuation.raise({into: true})),
     },
   ]);
 }