{"id":18484156,"url":"https://github.com/jdf2e/jdf-utils","last_synced_at":"2025-10-10T23:43:57.824Z","repository":{"id":57279955,"uuid":"73790241","full_name":"jdf2e/jdf-utils","owner":"jdf2e","description":"jdf-base","archived":false,"fork":false,"pushed_at":"2017-11-23T09:21:20.000Z","size":24,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-27T12:44:13.447Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdf2e.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2016-11-15T07:57:57.000Z","updated_at":"2024-05-14T22:57:03.000Z","dependencies_parsed_at":"2022-09-18T12:40:40.849Z","dependency_job_id":null,"html_url":"https://github.com/jdf2e/jdf-utils","commit_stats":null,"previous_names":["jdf2e/jdf-file"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jdf2e/jdf-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdf2e%2Fjdf-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdf2e%2Fjdf-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdf2e%2Fjdf-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdf2e%2Fjdf-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdf2e","download_url":"https://codeload.github.com/jdf2e/jdf-utils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdf2e%2Fjdf-utils/sbom","scorecard":{"id":512487,"data":{"date":"2025-08-11","repo":{"name":"github.com/jdf2e/jdf-utils","commit":"3da68518d4ee633b357a702391e51c1d534b78fc"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"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":"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":"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":"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":"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":"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":"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":"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":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"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":"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-20T00:57:11.969Z","repository_id":57279955,"created_at":"2025-08-20T00:57:11.969Z","updated_at":"2025-08-20T00:57:11.969Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005578,"owners_count":26083920,"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-10T02:00:06.843Z","response_time":62,"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-11-06T12:38:46.155Z","updated_at":"2025-10-10T23:43:57.795Z","avatar_url":"https://github.com/jdf2e.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NPM](https://nodei.co/npm/jdf-utils.png?downloads=true)](https://nodei.co/npm/jdf-utils/)\n\n[![NPM version](https://badge.fury.io/js/jdf-utils.png)](http://badge.fury.io/js/jdf-utils)  [![Build Status](https://travis-ci.org/jdf2e/jdf-utils.svg?branch=master)](https://travis-ci.org/jdf2e/jdf-utils)\n\n\n# jdf-utils\n\nJDF文件操作和基础函数类库\n\n## Install\n```\n$ npm install --save jdf-utils\n```\n\n## Usage\n```\nvar jdfUtils = require('jdf-utils');\nvar file = jdfUtils.file;\nvar base = jdfUtils.base;\n```\n\n## file api\n\n判断文件是否存在\n```\nfile.exists(path);\n```\n\n判断是否是文件\n```\nfile.isFile(path);\n```\n\n判断是否是文件夹\n```\nfile.isDir(path);\n```\n\n判断是否是空路径\n```\nfile.isBlankDir(path);\n```\n\n判断是否是windows系统\n```\nfile.isWin();\n```\n\n获取资源的真实路径\n```\nfile.realpath(path);\n```\n\n路径格式化，将`\\`替换为`/`\n```\nfile.pathFormat(path);\n```\n\n获取当前工作目录\n```\nfile.currentDir();\n```\n\n读取文件，默认文件编码为utf-8\n```\nfile.read(path [,encodeing]);\n```\n\n写文件，默认文件编码为utf-8\n```\nfile.write(path, source [,encoding]);\n```\n\n复制二进制文件\n```\nfile.copyBinary(path, target);\n```\n\n删除文件/文件夹\n```\nfile.del(path [,callback]);\n```\n\n文件过滤\n```\nfile.filter(path, [include, exclude]);\n```\n\n判断文件是否属于以下几种文件类型：`.git`，`.svn`，`Thumbs`，`DS_Store`，`.db`\n```\nfile.excludeFiles(path);\n```\n\n文件复制\n```\nfile.copy(path, target, [include, exclude, uncover, move]);\n```\n\n`@include`：想要复制的文件后缀，\n`@exclude`：不想复制的文件后缀，\n`@uncover`：是否不覆盖目标文件，默认为false，\n`@move`：想要移动文件，默认为false\n\n\n下载文件\n```\nfile.download(path, target);\n```\n\n创建文件夹\n```\nfile.mkdir(path);\n```\n\n读取文件列表\n```\nfile.getdirlist(path);\n```\n\n读取JSON文件\n```\nfile.readJSON(path);\n```\n\n重命名文件\n```\nfile.renameFile(path);\n```\n\n对文件base64编码\n```\nfile.base64Encode(path);\n```\n\n## base api\n\n检测是否存在和取widget name\n```\nbase.reg.widget();\n```\n\n获取widget type\n```\nbase.reg.widgetType();\n```\n\n获取widget data\n```\nbase.reg.widgetData();\n```\n\n获取widget 是否有注释\n```\nbase.reg.widgetComment();\n```\n\n获取widget position\n```\nbase.reg.widgetPosition();\n```\n\n获取当前页面输出的widget name\n```\nbase.reg.widgetOutputName();\n```\n\n获取被注释的widget\n```\nbase.reg.commentWidget();\n```\n\n获取非注释的widget\n```\nbase.reg.notCommentWidget();\n```\n\n匹配link标签\n```\nbase.reg.cssLink();\n```\n\n匹配script标签\n```\nbase.reg.jsLink();\n```\n\n匹配html注释\n```\nbase.reg.htmlComment();\n```\n判断是否为数据源文件，默认为json\n```\nbase.is.dataSource(path);\n```\n\n判断是否为tpl文件\n```\nbase.istpl(path);\n```\n\n判断是否为vm文件\n```\nbase.is.vm(path);\n```\n\n判断是否为smarty文件\n```\nbase.is.smarty(path);\n```\n\n判断是否为html文件\n```\nbase.is.html(path);\n```\n\n判断是否为css文件\n```\nbase.is.css(path);\n```\n\n判断是否为less文件\n```\nbase.is.less(path);\n```\n\n判断是否为sass文件\n```\nbase.is.sass(path);\n```\n\n判断是否为js文件\n```\nbase.is.js(path);\n```\n\n判断是否为jpg文件\n```\nbase.is.jpg(path);\n```\n\n判断是否为png文件\n```\nbase.is.png(path);\n```\n\n判断是否为http链接\n```\nbase.is.httpLink(str);\n```\n\n判断是否为图片文件：svg，tiff，wbmp，png，bmp，fax，gif，ico，jfif，jpe，jpeg，jpg，cur，eot，ttf，woff\n```\nbase.is.imageFile(str);\n```\n\n判断是否为babel文件\n```\nbase.is.babel(path);\n```\n\n去掉path的//\n```\nbase.replaceSlash(path);\n```\n\n拼接路径，并替换`\\`为`/`\n```\nbase.pathJoin(path);\n```\n\n去掉空格\n```\nbase.trim(str);\n```\n\n变量存在返回变量,变量不存在返回''\n```\nbase.getVar(str);\n```\n\n取当前日期\n```\nbase.getDay();\n```\n\n取当前时间\n```\nbase.getTime([separator, hasMs]);\n```\n\n`@separator`：分隔符，默认为冒号，\n`@hasMs`：是否返回毫秒数\n\n获取时间戳\n```\nbase.getTimestamp();\n```\n\n判断是否为数组\n```\nbase.isArray(obj);\n```\n\n获取css文件扩展名\n```\nbase.getCssExtname(path);\n```\n\n获取js文件扩展名\n```\nbase.getJsExtname(path);\n```\n\n获取url的参数\n```\nbase.getUrlParam(url);\n```\n\n发起http请求\n```\nbase.httpget(url);\n```\n\n数组去重\n```\nbase.uniq(array);\n```\n\n对象合并\n```\nbase.merageObj(obj1, obj2);\n```\n\n判断`array`是否包含`str`\n```\nbase.inArray(array, str);\n```\n\n返回字符串的md5值\n```\nbase.md5(str);\n```\n\n获取当前电脑用户信息\n* `username`，当前用户电脑帐户名称\n* `node_path`，当前电脑上的 nodejs 全局安装包位置\n* `pwd`，当前用户执行的项目路径\n```\nbase.getUserInfo();\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdf2e%2Fjdf-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdf2e%2Fjdf-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdf2e%2Fjdf-utils/lists"}