Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .eslintrc.json

This file was deleted.

33 changes: 18 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,33 @@ on:
pull_request:
branches: [master]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: purescript-contrib/setup-purescript@main
with:
purescript: "unstable"
- uses: actions/checkout@v6

- uses: actions/setup-node@v2
- uses: actions/setup-node@v6
with:
node-version: "14.x"
node-version: "24"

- name: Install dependencies
run: |
npm install -g bower
npm install
bower install --production
run: npm install

- name: Build source
run: npm run-script build
run: npm run build

- name: Run tests
run: |
bower install
npm run-script test --if-present
run: npm test

- name: Run benchmarks
run: npm run bench

- name: Lint
run: npm run lint

- name: Check formatting
run: npm run format:check
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/.*
!/.gitignore
!/.eslintrc.json
!/.tidyrc.json
!/.oxfmtrc.json
!/.github/
package-lock.json
/package-lock.json
/spago.lock
/bower_components/
/node_modules/
/output/
3 changes: 3 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"trailingComma": "es5"
}
10 changes: 10 additions & 0 deletions .tidyrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"importSort": "ide",
"importWrap": "source",
"indent": 2,
"operatorsFile": null,
"ribbon": 1,
"typeArrowPlacement": "first",
"unicode": "never",
"width": null
}
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Notable changes to this project are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [Unreleased](https://github.com/purescript/purescript-foreign-object/compare/v4.1.1...HEAD)

Breaking changes:

Expand All @@ -12,30 +12,42 @@ Bugfixes:

Other improvements:

## [v4.1.1](https://github.com/purescript/purescript-foreign-object/releases/tag/v4.1.1) - 2026-10-17

Other improvements:

- Migrate from Bower/Pulp to Spago and update CI, linting, formatting, and the benchmark runner (#31 by @thomashoneyman).

## [v4.1.0](https://github.com/purescript/purescript-foreign-object/releases/tag/v4.1.0) - 2022-10-27

New features:

- Add `fromFoldableWithIndex` (#30 by @ptrfrncsmrph)

## [v4.0.0](https://github.com/purescript/purescript-foreign-object/releases/tag/v4.0.0) - 2022-04-27

Breaking changes:

- Migrate FFI to ES modules (#27 by @JordanMartinez)

## [v3.0.0](https://github.com/purescript/purescript-foreign-object/releases/tag/v3.0.0) - 2021-02-26

Breaking changes:

- Added support for PureScript 0.14 and dropped support for all previous versions (#17)
- Fixed the `Semigroup` instance for `Foreign.Object.Object` (#19)

New features:

- Added roles declarations to allow safe coercions (#16)
- Added `unionWith` (#21)

Bugfixes:

- Fixed test using `Arbitrary` instance for `Instruction String v` (#22)

Other improvements:

- Migrated CI to GitHub Actions and updated installation instructions to use Spago (#20)
- Added a CHANGELOG.md file and pull request template (#24, #25)
- Improved docs for `runST` (#12)
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ example = do
-- convert homogeneous records to Object
converted = FO.fromHomogeneous { a: 1, b: 2, c: 3}
-- check that the converted is equal to a regularly built Object
built
= FO.empty
built = FO.empty
# FO.insert "a" 1
# FO.insert "b" 2
# FO.insert "c" 3
Expand Down
15 changes: 15 additions & 0 deletions bench/spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package:
name: foreign-object-bench
build:
strict: true
pedanticPackages: true
run:
main: Bench.Main
dependencies:
- console: ">=6.0.0 <7.0.0"
- effect: ">=4.0.0 <5.0.0"
- foreign-object: "*"
- lists: ">=7.0.0 <8.0.0"
- minibench: ">=4.0.0 <5.0.0"
- prelude: ">=6.0.0 <7.0.0"
- tuples: ">=7.0.0 <8.0.0"
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module Bench.Foreign.Object where

import Prelude
import Effect (Effect)
import Effect.Console (log)
import Performance.Minibench (benchWith)

import Data.Tuple (Tuple(..))
import Data.List as L
import Data.Tuple (Tuple(..))
import Effect (Effect)
import Effect.Console (log)
import Foreign.Object as Object
import Performance.Minibench (benchWith)

benchForeignObject :: Effect Unit
benchForeignObject = do
Expand All @@ -16,9 +16,10 @@ benchForeignObject = do

where
benchFromFoldable = do
let natStrs = show <$> L.range 0 99999
natPairs = (flip Tuple) unit <$> natStrs
shortPairList = L.take 10000 natPairs
let
natStrs = show <$> L.range 0 99999
natPairs = (flip Tuple) unit <$> natStrs
shortPairList = L.take 10000 natPairs

log $ "fromFoldable (" <> show (L.length shortPairList) <> ")"
benchWith 100 \_ -> Object.fromFoldable shortPairList
Expand Down
4 changes: 2 additions & 2 deletions bench/Bench/Main.purs → bench/src/Bench/Main.purs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Bench.Main where

import Prelude
import Effect (Effect)
import Effect.Console (log)

import Bench.Foreign.Object (benchForeignObject)
import Effect (Effect)
import Effect.Console (log)

main :: Effect Unit
main = do
Expand Down
42 changes: 0 additions & 42 deletions bower.json

This file was deleted.

23 changes: 13 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{
"private": true,
"scripts": {
"clean": "rimraf output && rimraf .pulp-cache",
"build": "eslint src && pulp build -- --censor-lib --strict",
"test": "pulp test",
"bench:build": "purs compile 'bench/**/*.purs' 'src/**/*.purs' 'bower_components/*/src/**/*.purs'",
"bench:run": "node -e 'require(\"./output/Bench.Main/index.js\").main()'",
"bench": "npm run bench:build && npm run bench:run"
"build": "spago build",
"test": "spago test -p foreign-object",
"bench:build": "spago build -p foreign-object-bench",
"bench:run": "spago run -p foreign-object-bench",
"bench": "npm run bench:build && npm run bench:run",
"lint": "oxlint --deny-warnings src test bench",
"format": "purs-tidy format-in-place src test bench && oxfmt --write .",
"format:check": "purs-tidy check src test bench && oxfmt --check ."
},
"devDependencies": {
"eslint": "^7.15.0",
"pulp": "16.0.0-0",
"purescript-psa": "^0.8.2",
"rimraf": "^3.0.2"
"oxfmt": "^0.73.0",
"oxlint": "^1.88.0",
"purescript": "^0.15.16",
"purs-tidy": "^0.11.1",
"spago": "^1.0.5"
}
}
39 changes: 39 additions & 0 deletions spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package:
name: foreign-object
description: Functions for working with homogeneous JavaScript objects
build:
strict: true
pedanticPackages: true
publish:
version: 4.1.1
license: BSD-3-Clause
location:
githubOwner: purescript
githubRepo: purescript-foreign-object
dependencies:
- arrays: ">=7.0.0 <8.0.0"
- foldable-traversable: ">=6.0.0 <7.0.0"
- functions: ">=6.0.0 <7.0.0"
- gen: ">=4.0.0 <5.0.0"
- lists: ">=7.0.0 <8.0.0"
- maybe: ">=6.0.0 <7.0.0"
- prelude: ">=6.0.0 <7.0.0"
- st: ">=6.0.0 <7.0.0"
- tailrec: ">=6.0.0 <7.0.0"
- tuples: ">=7.0.0 <8.0.0"
- typelevel-prelude: ">=7.0.0 <8.0.0"
- unfoldable: ">=6.0.0 <7.0.0"
- unsafe-coerce: ">=6.0.0 <7.0.0"
test:
main: Test.Main
strict: true
pedanticPackages: true
dependencies:
- assert: ">=6.0.0 <7.0.0"
- console: ">=6.0.0 <7.0.0"
- effect: ">=4.0.0 <5.0.0"
- ordered-collections: ">=3.0.0 <4.0.0"
- partial: ">=4.0.0 <5.0.0"
- quickcheck: ">=8.0.1 <9.0.0"
- transformers: ">=6.0.0 <7.0.0"
workspace: {}
10 changes: 7 additions & 3 deletions src/Foreign/Object.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ export function toArrayWithKey(f) {
};
}

export const keys = Object.keys || toArrayWithKey(function (k) {
return function () { return k; };
});
export const keys =
Object.keys ||
toArrayWithKey(function (k) {
return function () {
return k;
};
});
Loading
Loading