{"id":15070113,"url":"https://github.com/z41z/sp-func","last_synced_at":"2026-01-03T14:05:51.585Z","repository":{"id":32896358,"uuid":"145385166","full_name":"z41z/sp-func","owner":"z41z","description":"Common Functions for Url, Validate, Ajax etc.","archived":false,"fork":false,"pushed_at":"2022-12-02T18:38:10.000Z","size":287,"stargazers_count":0,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-22T20:51:51.639Z","etag":null,"topics":["ajax","fetch","frontend","function","javascript","loaddata","query","validate"],"latest_commit_sha":null,"homepage":"","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/z41z.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":"2018-08-20T07:56:21.000Z","updated_at":"2020-07-30T12:56:37.000Z","dependencies_parsed_at":"2023-01-14T22:34:26.772Z","dependency_job_id":null,"html_url":"https://github.com/z41z/sp-func","commit_stats":null,"previous_names":["z41z/sp-fe-func"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z41z%2Fsp-func","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z41z%2Fsp-func/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z41z%2Fsp-func/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z41z%2Fsp-func/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/z41z","download_url":"https://codeload.github.com/z41z/sp-func/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243846983,"owners_count":20357297,"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":["ajax","fetch","frontend","function","javascript","loaddata","query","validate"],"created_at":"2024-09-25T01:48:07.839Z","updated_at":"2026-01-03T14:05:51.556Z","avatar_url":"https://github.com/z41z.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sp-func\n\nCommon Functions for Url, Validate, Ajax etc\n\n***\n\n## Install\n\n### NPM\n\n``` node\nnpm install --save sp-func\n// or yarn add sp-func\n```\n\n### CDN\n\n```html\n\u003cscript src=\"https://unpkg.com/axios/dist/axios.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://unpkg.com/sp-func/index.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  __FUNC.serviceAPI(options = {\n    url: '/',\n    method: 'get',\n    data: {},\n    success: function () {},\n    fail: function () {},\n    headers: {}\n  });\n  __FUNC.serviceAPI({url: 'http://test.com/test.json'})\n\u003c/script\u003e\n```\n\n***\n\n## Usage\n\n```js\n //__FUNC: {serviceAPI, Validate, Url, Validate}\nconst __FUNC = require('sp-func')\n```\n\n### API Request\n\nBased on [axios](https://github.com/axios/axios).\n\n- **`serviceAPI (options = {})`**\n  - options\n    - `[url]`: `String`\n    - `[method]`: `String`\n    - `[data]`: `Object`\n    - `[success]`: `Function`\n    - `[fail]`: `Function`\n\n```js\n  __FUNC.serviceAPI({\n    url: 'http://test.com/test.json',\n    success: (res) =\u003e {\n      console.log(res)\n    }\n  })\n```\n\n### Validate\n\n- **`isEmail (email)`**\n  - `email`: `String`\n\n```js\n  __FUNC.Validate.isEmail('test@test.com')\n  //=\u003e true\n```\n\n- **`isEqual (str, compare, isDeep)`**\n  - `str`: `String`\n  - `compare`: `String`\n  - `[isDeep]`: `Boolean`\n\n```js\n  __FUNC.Validate.isEqual('123','123')\n  //=\u003e true\n\n  __FUNC.Validate.isEqual('123',123,true)\n    //=\u003e false\n```\n\nChinese IdCard Validate (length = 18)\n\n- **`isIdCard (id)`**\n  - `id`: `String`\n\n```js\n\n  __FUNC.Validate.isIdCard('51018419700106006X')\n  //=\u003e return {areaCode:510184,year:1970,month:01,day:06, gender:0}\n  //Boolean(return) = true\n\n  __FUNC.Validate.isIdCard('510184197001060060')\n  //=\u003e false\n```\n\n- **`isNumber (num, length)`**\n  - `num`: `String`\n  - `[length]`: `Number` default is `num.length`\n\n```js\n\n  __FUNC.Validate.isNumber('13619120030')\n  //=\u003e true\n\n  __FUNC.Validate.isNumber('12132535x')\n  //=\u003e false\n\n  __FUNC.Validate.isNumber('12132535x', 5)\n  //=\u003e true\n```\n\nChinese PhoneNumber Validate (length = 11)\n\n- **`isPhoneNumber (num)`**\n  - `num`: `String`\n\n```js\n\n  __FUNC.Validate.isPhoneNumber('13619120030')\n  //=\u003e true\n\n  __FUNC.Validate.isPhoneNumber('12132535')\n  //=\u003e false\n```\n\n- **`isEmpty (str)`**\n  - `str`: `String`\n\n```js\n\n  __FUNC.Validate.isEmpty('')\n  //=\u003e true\n\n  __FUNC.Validate.isEmpty('1')\n  //=\u003e false\n```\n\n### Url\n\n- **`getParams (url, keyName)`**\n  - `url`: `String`\n  - `[keyName]`: `String`\n\n```js\n  __FUNC.Url.getParams('http://test.com/user?id=23\u0026name=alice')\n  //=\u003e {id: 23, name: alice}\n\n  __FUNC.Url.getParams('http://test.com/user?id=23\u0026name=alice', 'name')\n  //=\u003e alice\n```\n\n### Storage\n\n- **`setStorage (name, value, isSession)`**\n  - `name`: `String`\n  - `value`: `String`\n  - `isSession`: `Boolean`\n\n```js\n  __FUNC.Storage.setStorage('age','18')\n  //=\u003e sessionStorage.age = 18\n\n  __FUNC.Storage.setStorage('age','19', false)\n  //=\u003e localStorage.age = 19\n```\n\n- **`getStorage (name, isSession)`**\n  - `name`: `String`\n  - `isSession`: `Boolean`\n\n```js\n  __FUNC.Storage.getStorage('age')\n  //=\u003e sessionStorage.age = 18\n\n  __FUNC.Storage.getStorage('age', false)\n  //=\u003e localStorage.age = 19\n```\n\n- **`Form.getData (name)`**\n  - `name`: `String`\n\n```js\n  __FUNC.Form.getData('age')\n  //=\u003e 18\n```\n\n- **`Form.setData (name, value)`**\n  - `name`: `String`\n  - `value`: `String`\n\n```js\n  __FUNC.Form.setData('age', 21)\n  __FUNC.Form.getData('age')\n  //=\u003e 21\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fz41z%2Fsp-func","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fz41z%2Fsp-func","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fz41z%2Fsp-func/lists"}