Skip to content

Commit

Permalink
(improve name to be more FP-style)
Browse files Browse the repository at this point in the history
  • Loading branch information
dslmeinte committed Sep 14, 2023
1 parent 4646256 commit bcaf392
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src-cli/serialization-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {writeFileSync} from "fs"
import {extname} from "path"

import {asText, deserializeLanguage, lioncoreQName, SerializationChunk} from "../src-pkg/index.js"
import {shortenSerialization, sortSerialization} from "../src-utils/serialization-utils.js"
import {shortenedSerialization, sortedSerialization} from "../src-utils/serialization-utils.js"
import {readFileAsJson, writeJsonAsFile} from "../src-utils/json.js"


Expand All @@ -21,9 +21,9 @@ export const extractFromSerialization = async (path: string) => {
try {
const json = readFileAsJson(path) as SerializationChunk
const extlessPath = path.substring(0, path.length - extname(path).length)
const sortedJson = sortSerialization(json)
const sortedJson = sortedSerialization(json)
writeJsonAsFile(extlessPath + ".sorted.json", sortedJson)
writeJsonAsFile(extlessPath + ".shortened.json", shortenSerialization(json)) // (could also sort)
writeJsonAsFile(extlessPath + ".shortened.json", shortenedSerialization(json)) // (could also sort)
if (isSerializedLanguage(json)) {
writeFileSync(extlessPath + ".txt", asText(deserializeLanguage(json)))
}
Expand Down
4 changes: 2 additions & 2 deletions src-test/m3/ecore/importer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {checkReferences, issuesLanguage, serializeLanguage} from "../../../src-p
import {asLIonCoreLanguage} from "../../../src-utils/m3/ecore/importer.js"
import {logIssues, logUnresolvedReferences, undefinedValuesDeletedFrom} from "../../utils/test-helpers.js"
import {libraryLanguage} from "../library-language.js"
import {sortSerialization} from "../../../src-utils/serialization-utils.js"
import {sortedSerialization} from "../../../src-utils/serialization-utils.js"


describe("Ecore importer", () => {
Expand All @@ -23,7 +23,7 @@ describe("Ecore importer", () => {
logIssues(issues)
deepEqual(issues, [])
const serialization = serializeLanguage(language)
deepEqual(sortSerialization(undefinedValuesDeletedFrom(serialization)), sortSerialization(undefinedValuesDeletedFrom(serializeLanguage(libraryLanguage))))
deepEqual(sortedSerialization(undefinedValuesDeletedFrom(serialization)), sortedSerialization(undefinedValuesDeletedFrom(serializeLanguage(libraryLanguage))))
})
})

Expand Down
4 changes: 2 additions & 2 deletions src-utils/serialization-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {SerializationChunk, sortByStringKey} from "../src-pkg/index.js"
* @return A shortened version of a {@link SerializedModel JSON serialization}, which should make it easier to inspect.
* Note that the shortened version doesn't contain all information, and could (in theory) be malformed.
*/
export const shortenSerialization = ({nodes}: SerializationChunk) =>
export const shortenedSerialization = ({nodes}: SerializationChunk) =>
nodes.map((node) => ({
id: node.id,
concept: node.concept.key,
Expand All @@ -24,7 +24,7 @@ export const shortenSerialization = ({nodes}: SerializationChunk) =>
* @return A sorted version of a {@link SerializedModel JSON serialization}, which should make it easier to inspect.
* Note that the sorted version destroy the order of links, which might effectively alter semantics.
*/
export const sortSerialization = ({serializationFormatVersion, languages, nodes}: SerializationChunk): SerializationChunk =>
export const sortedSerialization = ({serializationFormatVersion, languages, nodes}: SerializationChunk): SerializationChunk =>
({
serializationFormatVersion,
languages,
Expand Down

0 comments on commit bcaf392

Please sign in to comment.