{"id":13624292,"url":"https://github.com/binocarlos/len","last_synced_at":"2025-10-05T06:57:43.463Z","repository":{"id":15483251,"uuid":"18216879","full_name":"binocarlos/len","owner":"binocarlos","description":"Database for time based bookings of resources in leveldb","archived":false,"fork":false,"pushed_at":"2014-04-13T15:46:25.000Z","size":2502,"stargazers_count":29,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-05T06:57:42.128Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/binocarlos.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2014-03-28T15:30:43.000Z","updated_at":"2025-10-04T13:53:59.000Z","dependencies_parsed_at":"2022-07-13T23:10:33.616Z","dependency_job_id":null,"html_url":"https://github.com/binocarlos/len","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/binocarlos/len","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binocarlos%2Flen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binocarlos%2Flen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binocarlos%2Flen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binocarlos%2Flen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binocarlos","download_url":"https://codeload.github.com/binocarlos/len/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binocarlos%2Flen/sbom","scorecard":{"id":238911,"data":{"date":"2025-08-11","repo":{"name":"github.com/binocarlos/len","commit":"90e120ac6580c41666912bbebf215c876c2f21c1"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-17T06:16:12.153Z","repository_id":15483251,"created_at":"2025-08-17T06:16:12.153Z","updated_at":"2025-08-17T06:16:12.153Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278420211,"owners_count":25983814,"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","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08-01T21:01:41.120Z","updated_at":"2025-10-05T06:57:43.417Z","avatar_url":"https://github.com/binocarlos.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"len\n===\n\n![len logo](https://github.com/binocarlos/len/raw/master/graphics/logosmall.png \"Len Logo\")\n\n![Build status](https://api.travis-ci.org/binocarlos/len.png)\n\nCalendar database for resource bookings using leveldb\n\n## installation\n\n```\n$ npm install len\n```\n\n## usage\n\nYou create a len database by passing in an existing [leveldb](https://github.com/rvagg/node-levelup) - this can also be a [sub-level](https://github.com/dominictarr/level-sublevel)\n\n```js\nvar len = require('len');\nvar level = require('level');\n\n// create a new leveldb - this can also be a sub-level\nvar leveldb = level('/tmp/lentest');\n\n// create a new lem store using the leveldb\nvar lendb = len(db);\n```\n\nA booking represents a resource being used for a period of time.\n\nHere we create a booking for bob the mechanic:\n\n```js\n\n// start at 9.30\nvar start = new Date('04/03/14 09:30:00');\n// end at 13.30\nvar end = new Date('04/03/14 13:30:00');\n\nlendb.saveBooking('mechanics.bob', {\n\tid:14, \n\tstart:start,\n\tend:end,\n\tmeta:{\n\t\tname:'Fix Car',\n\t\tcustomer:34\n\t}\n}, function(error, booking){\n\n\t// bob is all booked in\n\n})\n```\n\nWe can ask len about bookings for all mechanics in a particular month:\n\n```js\nvar through = require('through');\nvar start = new Date('03/01/2014');\nvar end = new Date('04/01/2014').getTime();\n\nvar bookings_in_month = 0;\n\nlendb.createBookingStream('mechanics', {\n\tstart:start,\n\tend:end,\n\t// this means booking must start and end inside the window\n\tinclusive:true\n}).pipe(through(function(booking){\n\n\t// booking is an object with 'id', 'start', 'end' and 'meta' keys\n\tbookings_in_month++;\n\t\n}, function(){\n\tconsole.log('there are: ' + bookings_in_month.length + ' mechanic bookings in March');\n\n}))\n```\n\n## resource tree\n\nResources are created using paths and this can be a useful way to get booking reports at various layers.\n\nFor example - imagine we have a team that does some projects - we want to be able to ask the following questions:\n\n * the start and end point of one project\n * an array of bookings for one project\n * an array of bookings for all projects\n * an array of bookings between certain points for all projects\n\nThis can be done using the paths you give to resources - if we create resources with the following paths:\n\n * team.alpha.project.1\n * team.alpha.project.2\n\n## queries\n\nThen we can ask for the start and end for one project:\n\n```js\nlendb.getRange('team.alpha.project.1', function(err, bounds){\n\t// bounds.start = timestamp of the earliest start of booking for the project\n\t// bounds.end = timestamp of the latest end of booking for the project\n})\n```\n\nget a readstream of bookings:\n\n```js\n// bookings for one project\nlendb.createBookingStream('team.alpha.project.1').pipe(through(function(booking){\n\t// booking is an object\n}))\n\n// bookings for one team's projects\nlendb.createBookingStream('team.alpha.project')\n```\n\nget a readstream of bookings withing a time period\n\n```js\nvar start = new Date('03/04/14 09:30:00');\nvar end = new Date('03/04/14 13:30:00');\n\nlendb.createBookingStream('team.alpha.project', {\n\tstart:start,\n\tend:end\n})\n```\n\n## api\n\n#### `len(leveldb);`\n\nCreate a new len database from the provided [leveldb](https://github.com/rvagg/node-levelup).  This can be a [level-sublevel](https://github.com/dominictarr/level-sublevel) so you can partition len into an existing database.\n\n```js\nvar len = require('len');\nvar level = require('level');\n\nvar leveldb = level('/tmp/mylem');\nvar lendb = len(leveldb);\n```\n\n#### `lendb.loadBooking(resourcepath, bookingid, callback)`\n\nFetch a booking record using the resourcepath and booking id:\n\n```js\nlendb.loadBooking('project.1', 14, function(err, booking){\n\n\t// booking is an object with 'id', 'start', 'end' and 'meta' keys\n\n})\n```\n\n#### `lendb.saveBooking(resourcepath, booking, callback)`\n\nInsert/update a booking into the schedule for a resource.\n\nbooking is an object:\n\n``` js\n{\n\tid: 0,                   // the id of the booking you are saving - this is auto-created is left blank\n\tstart: Date(),           // the start timestamp of the booking\n\tend: Date(),             // the end timestamp of the booking\n\tmeta: {                  // an object with anything you like for the booking meta-data\n\t\tcustomer:12,\n\t\tcomments:'apples'\n\t}\n}\n```\n\nThe start and end timestamps are required - the meta object is converted to a JSON string and is returned in the 'meta' property of bookings.\n\n```js\nvar start = new Date('03/04/14 09:30:00');\nvar end = new Date('03/04/14 13:30:00');\n\nlendb.createBooking('project.1', {\n\tid:14,\n\tstart:start,\n\tend:end,\n\tmeta:{\n\t\tname:'meta data here'\n\t}\n}, function(err){\n\n\t// the booking is created for the resource\n\n})\n```\n\n#### `lendb.removeBooking(resourcepath, bookingid, callback)`\n\nRemove a booking from the schedule\n\n```js\nresource.removeBooking('project.1', 14, function(err){\n\n\t// the booking is removed\n\n})\n```\n\n#### `lendb.getRange(resourcepath, [window], callback)`\n\nUse this to get the start and end date for bookings in a resource\n\n```js\nlendb.getRange('projects.1', function(err, range){\n\t// range.start and range.end are timestamps\n})\n```\n\nYou can also pass a window to constrain the results:\n\n```js\nlendb.getRange('projects.1', {\n\tstart:start,\n\tend:end\n}, function(err, range){\n\n\t// range.start and range.end are timestamps\n\n})\n```\n\n#### `lendb.createBookingStream(resourcepath, [window], callback)`\n\nUse this to get an object stream of bookings for a given resource.\n\n```js\nvar through = require('through');\n\nlendb.createBookingStream('mechanics.bob', {\n\tstart:start,\n\tend:end\n}).pipe(through(function(booking){\n\n\tconsole.log('booking found');\n\tconsole.log(booking.id);\n\t\n}))\n```\n\nYou can also query the booking stream using a time-window:\n\n```js\nvar through = require('through');\nvar start = new Date('03/01/2014');\nvar end = new Date('04/01/2014').getTime();\n\nvar bookings_in_month = 0;\n\nlendb.createBookingStream('mechanics.bob', {\n\tstart:start,\n\tend:end,\n\tinclusive:true\n}).pipe(through(function(booking){\n\n\t// booking is an object with 'id', 'start', 'end' and 'meta' keys\n\tbookings_in_month++;\n\t\n}, function(){\n\tconsole.log('there are: ' + bookings_in_month.length + ' bookings for bob in March');\n\n}))\n```\n\nthe inclusive option controls whether bookings have to start and end inside the time window (true) or if any part of it is in the time window (false)\n\n## license\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinocarlos%2Flen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinocarlos%2Flen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinocarlos%2Flen/lists"}