{"id":23070162,"url":"https://github.com/strojure/zmap","last_synced_at":"2025-08-15T13:32:45.282Z","repository":{"id":64961813,"uuid":"579091604","full_name":"strojure/zmap","owner":"strojure","description":"Persistent map with lazily evaluated values for Clojure(Script).","archived":false,"fork":false,"pushed_at":"2023-03-09T13:37:49.000Z","size":39,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"default","last_synced_at":"2024-11-16T10:06:10.125Z","etag":null,"topics":["clojure","clojurescript","data-structures","delays","hashmap","lazy-evaluation"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/strojure.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-12-16T16:29:58.000Z","updated_at":"2023-07-25T15:05:24.000Z","dependencies_parsed_at":"2023-02-16T20:31:39.055Z","dependency_job_id":null,"html_url":"https://github.com/strojure/zmap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strojure%2Fzmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strojure%2Fzmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strojure%2Fzmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strojure%2Fzmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/strojure","download_url":"https://codeload.github.com/strojure/zmap/tar.gz/refs/heads/default","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229916373,"owners_count":18144130,"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":["clojure","clojurescript","data-structures","delays","hashmap","lazy-evaluation"],"created_at":"2024-12-16T06:19:52.941Z","updated_at":"2024-12-16T06:19:53.641Z","avatar_url":"https://github.com/strojure.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zmap\n\nPersistent map with lazily evaluated values for Clojure(Script).\n\n[![Clojars Project](https://img.shields.io/clojars/v/com.github.strojure/zmap.svg)](https://clojars.org/com.github.strojure/zmap)\n\n[![cljdoc badge](https://cljdoc.org/badge/com.github.strojure/zmap)](https://cljdoc.org/d/com.github.strojure/zmap)\n[![cljs compatible](https://img.shields.io/badge/cljs-compatible-green)](https://clojurescript.org/)\n[![tests](https://github.com/strojure/zmap/actions/workflows/tests.yml/badge.svg)](https://github.com/strojure/zmap/actions/workflows/tests.yml)\n\nPronounced as `[Zee Map]`.\n\n## Motivation\n\n* Access map values with delayed evaluation as ordinary map values.\n* Pass maps with delayed values to code which should not care that values are\n  delayed.\n\n## Features\n\n* Keep pending delayed values not realized until used.\n* Do not mix zmap delays with delays created by `clojure.core/delay`.\n* Support `IFn` interface of persistent map.\n* Support transients.\n* Transparent IPersistentMap behaviour with minimal overhead.\n* The `toString` does not realize delayed values, shows them like delays.\n\n## API\n\n### `wrap`/`delay`\n\nThe function `zmap/wrap` is used to wrap Clojure map having values created with\n`zmap/delay` to access those values directly without `deref`.\n\n```clojure\n(ns api.core-wrap-delay\n  \"Example of `zmap/wrap` with `zmap/delay`.\"\n  (:require [strojure.zmap.core :as zmap]))\n\n(def ^:private -map\n  (zmap/wrap {:a (zmap/delay (println \"Init\") 1)}))\n\n(get -map :a)\n;Init\n;=\u003e 1\n```\n\n### `update`\n\nThe function `zmap/update` is used for delayed map update. Returns instance of\nthe same type as input, so standard maps should be wrapped afterwards.\n\n```clojure\n(ns api.core-update\n  \"Example of `zmap/update`.\"\n  (:require [strojure.zmap.core :as zmap]))\n\n(def ^:private -map1\n  (-\u003e {:a 1}\n      (zmap/update :a (fn [x]\n                        (println \"Update\")\n                        (inc x)))\n      (zmap/wrap)))\n\n(get -map1 :a)\n;Update\n;=\u003e 2\n\n(def ^:private -map2\n  (-\u003e (zmap/wrap {:a (zmap/delay (println \"Init\") 1)})\n      (zmap/update :a (fn [x]\n                        (println \"Update\")\n                        (inc x)))))\n\n(get -map2 :a)\n;Init\n;Update\n;=\u003e 2\n```\n\n### `with-map`\n\nThe macro `zmap/with-map` is used to make multiple transformations of underlying\nClojure map with decreased overhead caused by zmap proxying.\n\n```clojure\n(ns api.core-with-map\n  \"Example of `zmap/with-map`.\"\n  (:require [strojure.zmap.core :as zmap]))\n\n;; We work with non-wrapped map inside `zmap/with-map` macro.\n\n(zmap/with-map [m (zmap/wrap {})]\n  ;; work with non-wrapped map here\n  (println \"Inside:\" (class m))\n  (assoc m :a (zmap/delay 1)))\n;Inside: clojure.lang.PersistentArrayMap\n;=\u003e {:a 1}\n\n;; The result of `with-map` body is wrapped back to zmap.\n\n(class (zmap/with-map [m (zmap/wrap {})]\n         (assoc m :a (zmap/delay 1))))\n;=\u003e strojure.zmap.impl.clj.PersistentMapProxy\n```\n\n## Performance\n\nSee benchmarks [here](doc/benchmarks/compare.clj).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrojure%2Fzmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstrojure%2Fzmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrojure%2Fzmap/lists"}