npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mapservice

v1.0.5

Published

data store service

Downloads

11

Readme

A JS data store and Component communication service

Install

  1. npm install mapservice

Basic description

  1. Js global access data store

  2. Complete inter-component communication and data transfer

  3. Smaller and more refined data layer than vuex, does not depend on any framework

API

1. DataStore

Js global access data store

/*
* js 数据层
* @author fengjiabao
* @link:  https://github.com/fengjiabao/mapService
* @version 1.0.5
*/
import mapService from 'mapservice' //   or   var  mapService = require("mapservice") 

// set data
mapService.DataStore.set('loginStatus' : {
   login: "true",
   cookie: "p00001"
} )

mapService.DataStore.set("userList" : [liming,liliy, wangfei])

mapService.DataStore.set("userNumber" : 15)

//get data
mapService.DataStore.get("loginStatus")

//update data
mapService.DataStore.set("loginStatus",{ //set all value
   login: "false",
   cookie: "p00002"
})

mapService.DataStore.setObjVal("loginStatus.login","false") //Set obj a key value

mapService.DataStore.setObjVal("loginStatus.cookie",["p0001","p0003"]) //Set obj a key value

// delete data
mapService.DataStore.delete("loginStatus")

//Get whether there is a key
mapService.DataStore.hasKey("loginStatus")

// clear mapService dataStore
mapService.DataStore.clear()

//get store values
mapService.DataStore.values()

//get store keys
mapService.DataStore.keys()

//get store size
mapService.DataStore.size()
Data persistence, when pages refresh, such as vue-router refresh
//before refresh
mapService.DataStore.setSessionJson(key,obj)

//after refresh
mapService.DataStore.getSessionJson(key,obj)

2. dataService

Complete inter-component communication and data transfer

eg1:
//component 1,before mounted
mapService.on("goLogin",function(data){
	data.user && data.pwd && goLogin() 
})

//component 2, trigger event
mapService.trigger("goLogin",{
	user: "nike",
    pwd: "123"
})
eg2:
//Registered in main.js
mapService.on("goLogin",function(data){
	data.user && data.pwd && goLogin() 
})

//async event
axios.post("//www.npmjs.com",params,function(data){
	mapService.trigger("goLogin",data)
})
eg3: Multiple subscribers
//component 1,before mounted
mapService.on("goLogin",function(data){
	data.user && data.pwd && goLogin() 
})

 //component 3,before mounted
mapService.on("goLogin",function(data){
	data.user && data.pwd && goLogin() 
})

//component 2, trigger event
mapService.trigger("goLogin",{
	user: "nike",
    pwd: "123"
})
Execute once:
//Registered in main.js
mapService.once("goLogin",function(data){
	data.user && data.pwd && goLogin() 
})

//async event
axios.post("//www.npmjs.com",params,function(data){
	mapService.trigger("goLogin",data)
})
off event:
mapService.off("goLogin")

If you have any interest or question, welcome to fork https://github.com/fengjiabao/mapService