Skip to content

Commit

Permalink
v0.4.0 (#20)
Browse files Browse the repository at this point in the history
* update packages to latest version and remove tests

* explicitly state function parameters and return types

* use old config name until client uses newest rescript version
  • Loading branch information
cbowling authored Jul 15, 2024
1 parent 7697c37 commit 5e9ca9c
Show file tree
Hide file tree
Showing 12 changed files with 391 additions and 4,895 deletions.
15 changes: 3 additions & 12 deletions bsconfig.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
{
"name": "@ninefx/bs-xml",
"version": "0.3.1",
"version": "0.4.0",
"sources": [
{
"dir": "src",
"subdirs": true
},
{
"dir": "test",
"type": "dev"
}
],
"package-specs": {
"module": "commonjs",
"in-source": true
"module": "commonjs"
},
"suffix": ".bs.js",
"bs-dev-dependencies": [
"@glennsl/bs-jest"
],
"bs-dependencies": [
"rescript-webapi"
],
"warnings": {
"error": "+101"
},
"refmt": 3
}
}
5 changes: 0 additions & 5 deletions jest.config.js

This file was deleted.

32 changes: 18 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
{
"name": "@zpnester/bs-xml",
"description": "DOM Document decode API for BuckleScript",
"version": "0.3.0",
"name": "@ninefx/bs-xml",
"description": "DOM Document decode API for ReScript",
"version": "0.4.0",
"repository": {
"type": "git",
"url": "https://github.com/zpnester/bs-xml.git"
"url": "https://github.com/NineFX/bs-xml.git"
},
"author": {
"name": "Andriy Nesterenko",
"email": "[email protected]",
"url": "https://github.com/zpnester"
},
"contributors": [
"Eric S Bullington <[email protected]>",
"Joey Eckstrom <[email protected]>",
"Chris Bowling <[email protected]>",
"Drew Varner <[email protected]>",
"Samuel Nichols <[email protected]>"
],
"scripts": {
"clean": "rescript clean -with-deps",
"build": "rescript build",
"watch": "rescript build -w",
"test:watch": "jest --watchAll",
"test": "jest",
"webpack-dev-server": "webpack-dev-server",
"start": "concurrently --raw npm:watch npm:webpack-dev-server"
},
"keywords": [
"BuckleScript",
"ReScript",
"DOMParser",
"Document",
"XML",
"browser"
],
"license": "MIT",
"devDependencies": {
"@glennsl/bs-jest": "^0.7.0",
"concurrently": "7.4.0",
"copy-webpack-plugin": "11.0.0",
"html-webpack-plugin": "5.5.0",
"webpack": "^5.74.0"
"concurrently": "8.2.2",
"copy-webpack-plugin": "12.0.2",
"html-webpack-plugin": "5.6.0",
"webpack": "^5.92.1"
},
"dependencies": {
"rescript": "^10.0.1",
"rescript-webapi": "^0.6.1"
"rescript": "^11.1.2",
"rescript-webapi": "^0.9.1"
}
}
12 changes: 5 additions & 7 deletions src/Xml_Decode.res
Original file line number Diff line number Diff line change
Expand Up @@ -128,25 +128,23 @@ let children = (selector: Xml_Element.t => bool, decoder: decoder<'a>, element:
->Xml_NodeList.asArrayLike
->Belt.Array.keepMap(Xml_Node.asElement)
->Belt.Array.keep(selector)
->Belt.Array.map(decoder)
->Belt.Array.map(decoder(_))
}

let map = (decoder: decoder<'a>, f: 'a => 'b, elem) => decoder(elem)->f

let mapOptional = (decoder: decoder<option<'a>>, f: 'a => 'b, elem) =>
decoder(elem)->Belt.Option.map(f)
decoder(elem)->Option.map(f)

let andThen = (decoder: decoder<'a>, f: 'a => decoder<'b>, elem) => {
let a = decoder(elem)
f(a, elem)
}
let andThen = (decoder: decoder<'a>, f: 'a => decoder<'b>, elem) =>
decoder(elem)->f

let either = (left: decoder<'a>, right: decoder<'a>, elem: Xml_Element.t) =>
try left(elem) catch {
| DecodeError(_) => right(elem)
}

let withDefault = (decoder, default, elem: Xml_Element.t) =>
let withDefault = (decoder: decoder<'a>, default, elem: Xml_Element.t) =>
try decoder(elem) catch {
| DecodeError(_) => default
}
Expand Down
28 changes: 14 additions & 14 deletions src/Xml_Decode.resi
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@ let namespace: Xml_Element.t => option<string>

let name: Xml_Element.t => string

let ok: 'a => decoder<'a>
let error: string => decoder<'a>
let ok: ('a, Xml_Element.t) => 'a
let error: (string, Xml_Element.t) => string

// require* functions throws DecodeError, can be used in custom decoders

let requireSome: option<'a> => 'a
let requireName: (Xml_Element.t, string) => Xml_Element.t
let requireNamespace: (Xml_Element.t, option<string>) => Xml_Element.t

let attribute: (~namespace: string=?, string) => decoder<string>
let attribute: (~namespace: string=?, string, Xml_Element.t) => string

let withName: (string, decoder<'a>) => decoder<'a>
let withNamespace: (option<string>, decoder<'a>) => decoder<'a>
let optional: decoder<'a> => decoder<option<'a>>
let withName: (string, decoder<'a>, Xml_Element.t) => 'a
let withNamespace: (option<string>, decoder<'a>, Xml_Element.t) => 'a
let optional: (decoder<'a>, Xml_Element.t) => option<'a>

// select* functions are used in 'child' and 'children' decoders

let selectAny: Xml_Element.t => bool
let select: (~namespace: option<string>=?, string, Xml_Element.t) => bool

let child: (Xml_Element.t => bool, decoder<'a>) => decoder<'a>
let children: (Xml_Element.t => bool, decoder<'a>) => decoder<array<'a>>
let map: (decoder<'a>, 'a => 'b) => decoder<'b>
let mapOptional: (decoder<option<'a>>, 'a => 'b) => decoder<option<'b>>
let andThen: (decoder<'a>, 'a => decoder<'b>) => decoder<'b>
let either: (decoder<'a>, decoder<'a>) => decoder<'a>
let withDefault: (Xml_Element.t => 'a, 'a) => decoder<'a>
let oneOf: list<decoder<'a>> => decoder<'a>
let child: (Xml_Element.t => bool, decoder<'a>, Xml_Element.t) => 'a
let children: (Xml_Element.t => bool, decoder<'a>, Xml_Element.t) => array<'a>
let map: (decoder<'a>, 'a => 'b, Xml_Element.t) => 'b
let mapOptional: (decoder<option<'a>>, 'a => 'b, Xml_Element.t) => option<'b>
let andThen: (decoder<'a>, 'a => decoder<'b>, Xml_Element.t) => decoder<'b>
let either: (decoder<'a>, decoder<'a>, Xml_Element.t) => 'a
let withDefault: (decoder<'a>, 'a, Xml_Element.t) => 'a
let oneOf: (list<decoder<'a>>, Xml_Element.t) => 'a

let float: string => float
let int: string => int
Expand Down
2 changes: 0 additions & 2 deletions test/Expect_.res

This file was deleted.

Loading

0 comments on commit 5e9ca9c

Please sign in to comment.