Skip to content

Commit

Permalink
Upgrade @freckle/non-empty
Browse files Browse the repository at this point in the history
  • Loading branch information
stackptr committed Jan 17, 2024
1 parent 286b1e3 commit 6c757d7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
Binary file modified .yarn/install-state.gz
Binary file not shown.
6 changes: 5 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ function nonEmptyArray(parser) {
if (!Array.isArray(xs) || xs.length === 0) {
return exports.Parser.fail({ expected, got: xs });
}
return collect(parser, xs, { path, expected });
const parsed = (0, non_empty_1.mkNonEmpty)(xs);
if (parsed === null) {
return exports.Parser.fail({ expected, got: xs });
}
return collect(parser, parsed, { path, expected });
}
};
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freckle/parser",
"version": "1.3.3",
"version": "2.0.0",
"description": "One that parses",
"main": "./dist/index.js",
"repository": "https://github.com/freckle/parser-js.git",
Expand All @@ -14,7 +14,7 @@
},
"dependencies": {
"@freckle/exhaustive": "^1.0.1",
"@freckle/non-empty": "^2.1.2",
"@freckle/non-empty": "^3.0.0",
"lodash": "4.17.21",
"moment-timezone": "0.5.35"
},
Expand Down
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import reduce from 'lodash/reduce'
import _map from 'lodash/map' // Underscored to avoid name clash
import find from 'lodash/find'
import moment, {type Moment} from 'moment-timezone'
import {type NonEmptyArray, mkNonEmptyFromHead, unconsOnNonEmpty} from '@freckle/non-empty'
import {type NonEmptyArray, mkNonEmpty, mkNonEmptyFromHead, unconsOnNonEmpty} from '@freckle/non-empty'

import Path from './path'
import {type PathT} from './path'
Expand Down Expand Up @@ -280,7 +280,13 @@ export function nonEmptyArray<R>(parser: ParserT<R>): ParserT<NonEmptyArray<R>>
if (!Array.isArray(xs) || xs.length === 0) {
return Parser.fail({expected, got: xs})
}
return collect(parser, xs, {path, expected})

const parsed = mkNonEmpty(xs)
if (parsed === null) {
return Parser.fail({expected, got: xs})
}

return collect(parser, parsed, {path, expected}) as ParseResultT<NonEmptyArray<R>>
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1339,13 +1339,13 @@ __metadata:
languageName: node
linkType: hard

"@freckle/non-empty@npm:^2.1.2":
version: 2.1.2
resolution: "@freckle/non-empty@npm:2.1.2"
"@freckle/non-empty@npm:^3.0.0":
version: 3.0.0
resolution: "@freckle/non-empty@npm:3.0.0"
dependencies:
"@freckle/maybe": "npm:^2.1.0"
lodash: "npm:4.17.21"
checksum: de332f6beb436a3f111c74dace86506e66af6423e4b69bf9c031880c034e4a378e071a0e4c32b89a1f04668e12a5507449e15b9b8f1eced42681d7a1b37cf712
checksum: 942f2f307bc8f4e6a87565c87c53b1fccd1340eb6068f197915230892fb5bac86b5ca6d868e034c26cd479349024eb7f7b504e787c838931255978cdc752a9fe
languageName: node
linkType: hard

Expand All @@ -1357,7 +1357,7 @@ __metadata:
"@babel/core": "npm:^7.17.0"
"@babel/preset-env": "npm:^7.16.11"
"@freckle/exhaustive": "npm:^1.0.1"
"@freckle/non-empty": "npm:^2.1.2"
"@freckle/non-empty": "npm:^3.0.0"
"@types/jest": "npm:^28.1.1"
"@types/lodash": "npm:^4.14.182"
jest: "npm:^27.4.7"
Expand Down

0 comments on commit 6c757d7

Please sign in to comment.