{"id":22196796,"url":"https://github.com/druids/tol","last_synced_at":"2025-03-24T22:41:08.801Z","repository":{"id":62435399,"uuid":"113545165","full_name":"druids/tol","owner":"druids","description":"A Tól is a set of functions that extend Clojure core functions","archived":false,"fork":false,"pushed_at":"2018-08-08T11:02:43.000Z","size":39,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-04T22:06:15.655Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/druids.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-08T07:27:04.000Z","updated_at":"2018-08-08T11:02:44.000Z","dependencies_parsed_at":"2022-11-01T21:15:51.397Z","dependency_job_id":null,"html_url":"https://github.com/druids/tol","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/druids%2Ftol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/druids%2Ftol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/druids%2Ftol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/druids%2Ftol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/druids","download_url":"https://codeload.github.com/druids/tol/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245366207,"owners_count":20603438,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-02T14:16:30.703Z","updated_at":"2025-03-24T22:41:08.782Z","avatar_url":"https://github.com/druids.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"Tól\n===\n\nTól is a set of functions that extend Clojure/ClojureScript core functions. A lot of Clojure core functions are just\n wrappers over Java classes/methods. Thus these functions are more Java-like (they throw `NullPointerException`), but\n this behaviour isn't expected in Clojure world. Clojure's functions for sequences aren't NPE-prone, but others do\n (e.g. `string` module). All Tól functions are designed not to be NPE-prone (rather return `nil`, instead of throw NPE)\n thus they can be used e.g. in `some-\u003e` macro.\n\n[![CircleCI](https://circleci.com/gh/druids/tol.svg?style=svg)](https://circleci.com/gh/druids/tol)\n[![Dependencies Status](https://jarkeeper.com/druids/tol/status.png)](https://jarkeeper.com/druids/tol)\n[![License](https://img.shields.io/badge/MIT-Clause-blue.svg)](https://opensource.org/licenses/MIT)\n\n\nLeiningen/Boot\n--------------\n\n```clojure\n[tol \"0.9.0\"]\n```\n\n\nDocumentation\n-------------\n\n\n### -\u003eint\nCoerce a given input as an `integer`. If the input is not an `integer` it returns `nil`.\n\n```clojure\n(tol/-\u003eint 1) ;; 1\n(tol/-\u003eint \"1\") ;; 1\n(tol/-\u003eint nil) ;; nil\n(tol/-\u003eint \"\") ;; nil\n```\n\n### -\u003euuid\nCoerce a given `value` as `java.util.UUID`. When the `value` is not a valid UUID, it returns `nil`.\nIn ClojureScript there is not UUID class/function (not even in Google Closure Library). Thus in ClojureScript\nit returns just `string` value for non-blank `value`.\n\n```clojure\n(tol/-\u003euuid \"59537428-0b92-4d3a-9192-bcbae9a18889\") ;; #uuid \"59537428-0b92-4d3a-9192-bcbae9a18889\"\n(tol/-\u003euuid nil) ;; nil\n(tol/-\u003euuid \"\") ;; nil\n(tol/-\u003euuid \"asdf\") ;; nil\n```\n\n### lowerf\nLower cases first character of a given `value`. It's safe, when the `value` is `nil` or empty `string` returns `nil`,\n otherwise `string.`\n\n```clojure\n(tol/lowerf nil) ;; nil\n(tol/lowerf \"\") ;; nil\n(tol/lowerf \"ABC\") ;; \"aBC\"\n```\n\n### upperf\nUpper cases first character of a given `value`. It's safe, when the `value` is `nil` or empty `string` returns `nil`,\n otherwise `string.`\n\n```clojure\n(tol/upperf nil) ;; nil\n(tol/upperf \"\") ;; nil\n(tol/upperf \"abC\") ;; \"AbC\"\n```\n\n### if-let*\nIt's if-let with multiple bindings. It allows to flatten and simplify some code nesting.\n\nIt doesn't work in ClojureScript.\n\n```clojure\n(tol/if-let*\n  [a 1\n   b (+ a 1)]\n  b) ;; 2\n\n(tol/if-let*\n  [a 1\n   b (+ a 1)\n   c false]\n  :then\n  :else) ;; :else\n\n(tol/if-let*\n  [a 1\n   b nil]\n  a) ;; nil\n```\n\n### non-blank\nReturn a given `input` when it isn't `nil`. Otherwise `nil` is returned. It's useful for `some-\u003e` macros.\n\n```clojure\n(tol/non-blank nil) ;; nil\n(tol/non-blank \"\") ;; nil\n(tol/non-blank \" \") ;; nil\n(tol/non-blank \"abC\") ;; \"AbC\"\n```\n\n### update-keys\nApplies a given function `f` on every key in a given associative structure `m`, where `f` is a function\nthat will take a key-name and any supplied args and return new value.\n\n```clojure\n(tol/update-keys inc {0 :a}) ;; {1 :a}\n(tol/update-keys inc nil) ;; nil\n(tol/update-keys inc {}) ;; nil\n(tol/update-keys + 2 {0 :a}) ;; {2 :a}\n(tol/update-keys + 2 1 {0 :a}) ;; {3 :a}\n(tol/update-keys + 3 2 1 {0 :a}) ;; {6 :a}\n(tol/update-keys (fn [init a b c more] (apply + (concat [init a b c] more))) 4 3 2 [1] {0 :a}) ;; {10 :a}\n```\n\n### update-vals\nApplies a given function `f` on every value in a given `coll`\n\n```clojure\n(tol/update-vals inc {:a 0}) ;; {:a 1}\n(tol/update-vals inc nil) ;; nil\n(tol/update-vals inc {}) ;; {}\n```\n\n### case+\nSame as case, but evaluates dispatch values, needed for referring to class and defined constants as well as\njava.util.Enum instances.\n\nIt doesn't work in ClojureScript.\n\n```clojure\n(tol/case+ java.util.concurrent.TimeUnit/SECONDS\n  java.util.concurrent.TimeUnit/SECONDS :seconds\n  nil) ;; :seconds\n\n(tol/case+ nil\n  java.util.concurrent.TimeUnit/SECONDS :seconds\n  nil) ;; nil\n\n(tol/case+ 1\n  java.util.concurrent.TimeUnit/SECONDS :seconds\n  nil) ;; nil\n```\n\n\nContribution\n------------\n\n### Conventions\n\n* Please follow coding style defined by [`.editorconfig`](http://editorconfig.org)\n and [The Clojure Style Guide](https://github.com/bbatsov/clojure-style-guide)\n* Write [good commit messages](https://chris.beams.io/posts/git-commit/)\n and provide an issue ID in a commit message prefixed by `#`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdruids%2Ftol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdruids%2Ftol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdruids%2Ftol/lists"}