From 137f1c8a0a79fbd8c1ef4faf7a9030621e35789e Mon Sep 17 00:00:00 2001 From: mikaello <2505178+mikaello@users.noreply.github.com> Date: Tue, 2 Apr 2019 17:13:04 +0200 Subject: [PATCH] Add demo/example project, showing how to use this library --- README.md | 2 ++ example/.gitignore | 30 ++++++++++++++++++++++++++++++ example/LICENSE | 21 +++++++++++++++++++++ example/README.md | 20 ++++++++++++++++++++ example/bsconfig.json | 17 +++++++++++++++++ example/package.json | 16 ++++++++++++++++ example/src/Demo.re | 14 ++++++++++++++ example/yarn.lock | 39 +++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 9 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 example/.gitignore create mode 100644 example/LICENSE create mode 100644 example/README.md create mode 100644 example/bsconfig.json create mode 100644 example/package.json create mode 100644 example/src/Demo.re create mode 100644 example/yarn.lock diff --git a/README.md b/README.md index b654d6d..cf57424 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,8 @@ Js.log(cleanedKeepStrings); /* => { biz: 'baz', foo: '', qux: { baz: 'boz', txi: '' } } */ ``` +See also [example-project](./example). + ## Contribute If you find bugs or there are updates in [clean-deep](https://github.com/nunofgs/clean-deep), feel free to open an issue or PR. If you are upgrading any dependencies, please use yarn so `yarn.lock` is updated. diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..8ca74db --- /dev/null +++ b/example/.gitignore @@ -0,0 +1,30 @@ +# Reason / Bucklescript +lib +.merlin +.bsb.lock +*.bs.js + +# idea +.vscode + +# OSX files +*.DS_Store + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Dependency directories +node_modules/ + +# Optional npm cache directory +.npm + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity diff --git a/example/LICENSE b/example/LICENSE new file mode 100644 index 0000000..6acaa36 --- /dev/null +++ b/example/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 mikaello + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..32fc802 --- /dev/null +++ b/example/README.md @@ -0,0 +1,20 @@ +# Demo project for bs-clean-deep + +This project is only for testing that the [bs-clean-deep](https://github.com/mikaello/bs-clean-deep) bindings works as expected. + +## Build +``` +yarn build +``` + +## Build + Watch + +``` +yarn start +``` + +## Run + +``` +node src/Demo.bs.js +``` diff --git a/example/bsconfig.json b/example/bsconfig.json new file mode 100644 index 0000000..866052f --- /dev/null +++ b/example/bsconfig.json @@ -0,0 +1,17 @@ +{ + "name": "bs-clean-deep-demo", + "version": "0.1.0", + "sources": { + "dir" : "src", + }, + "package-specs": { + "module": "commonjs", + "in-source": true + }, + "suffix": ".bs.js", + "bs-dependencies": [ + "bs-clean-deep" + ], + "namespace": true, + "refmt": 3 +} diff --git a/example/package.json b/example/package.json new file mode 100644 index 0000000..1e9fa87 --- /dev/null +++ b/example/package.json @@ -0,0 +1,16 @@ +{ + "name": "bs-clean-deep-demo", + "version": "0.1.0", + "scripts": { + "build": "bsb -make-world", + "start": "bsb -make-world -w", + "clean": "bsb -clean-world" + }, + "license": "MIT", + "devDependencies": { + "bs-platform": "^5" + }, + "dependencies": { + "bs-clean-deep": "^0.1.0" + } +} diff --git a/example/src/Demo.re b/example/src/Demo.re new file mode 100644 index 0000000..bfafeff --- /dev/null +++ b/example/src/Demo.re @@ -0,0 +1,14 @@ +open BsCleanDeep; + +Js.log("Demo of 'bs-clean-deep'\n"); + +let s = [%bs.raw {| { emptystring: '', foo: 3, emptyobject: {} } |}]; + +Js.log("No options:"); +Js.log(CleanDeep.cleanDeep(s)); + +Js.log("\nWith empty objects preserved:"); +Js.log(s |> CleanDeep.cleanDeep(~emptyObjects=false)); + +Js.log("\nWith empty objects and strings preserved:"); +Js.log(CleanDeep.cleanDeep(~emptyObjects=false, ~emptyStrings=false, s)); \ No newline at end of file diff --git a/example/yarn.lock b/example/yarn.lock new file mode 100644 index 0000000..91d88fb --- /dev/null +++ b/example/yarn.lock @@ -0,0 +1,39 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +bs-clean-deep@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/bs-clean-deep/-/bs-clean-deep-0.1.0.tgz#01cfe17d1706cfa1cecb80c7b16b695e2683f758" + integrity sha512-W6zbZIHwDUylG4oBNAt+98tkMXOgD3MPCFPnQZdsz1XvXj17cY23vhgTmGON2TbiQc3vvm1bYSo3LjZhIe5PdQ== + dependencies: + clean-deep "^3.0.2" + +bs-platform@^5: + version "5.0.0" + resolved "https://registry.yarnpkg.com/bs-platform/-/bs-platform-5.0.0.tgz#f9fded818bafc3891aeb85eb4e0d95b8d8f8b4d7" + integrity sha512-zxLobdIaf/r7go47hOgxcd6C0ANh7MYMEtZNb9Al7JdoekzFZI50F4GpZpP8kMh9Z+M5PoPE1WuryT4S8mT8Kg== + +clean-deep@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/clean-deep/-/clean-deep-3.0.2.tgz#1b7096822f289cc491ca6d85af5c028cbb22fc23" + integrity sha512-sLUtFxYtHc3jM9pmwyYXOLln0nnQ1OhFrefQ7nqUlva1crHDbi4gVO+nnMSm5jztFXIRDMt+kMNh0mOscbARow== + dependencies: + lodash.isempty "^4.4.0" + lodash.isplainobject "^4.0.6" + lodash.transform "^4.6.0" + +lodash.isempty@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.isempty/-/lodash.isempty-4.4.0.tgz#6f86cbedd8be4ec987be9aaf33c9684db1b31e7e" + integrity sha1-b4bL7di+TsmHvpqvM8loTbGzHn4= + +lodash.isplainobject@^4.0.6: + version "4.0.6" + resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb" + integrity sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs= + +lodash.transform@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.transform/-/lodash.transform-4.6.0.tgz#12306422f63324aed8483d3f38332b5f670547a0" + integrity sha1-EjBkIvYzJK7YSD0/ODMrX2cFR6A= diff --git a/package.json b/package.json index 5f7c996..8adca19 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bs-clean-deep", - "version": "1.0.0", + "version": "1.0.1", "scripts": { "build": "bsb -make-world", "start": "bsb -make-world -w",