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

stickyants-sp-util

v1.0.1

Published

A set of utility functions and classes to simplify working with JSOM for SharePoint Online/2013/2016 development.

Downloads

4

Readme

stickyants-sp-util

A set of utility functions and classes to support SharePoint development using JSOM. The library simplifies some of the tasks and uses ES6 promises to wrap executeQueryAsync calls such that they work nicely together.

1 Term Store (Taxonomy)

1.1 Working with the term store


import {createTermStore} from 'stickyants-sp-util'; 


var store = createTermStore(); 

//to get all terms of a term set
var terms = await store.getAllTermsByTermSetId('11365da4-d7cd-43b3-9d28-9d43b0313f2f'); 

2 Link Generation

2.1 Generate link to user picture by user email address


import {getUserPictureLink} from 'stickyants-sp-util'; 


var pictureUrl = getUserPictureLink('[email protected]');

2.2 Generate delve profile of user by email user email address


import {getUserDelveLink} from 'stickyants-sp-util'; 


var delveLink = getUserDelveLink('[email protected]');

2.3 Generate a link to specific version of the current page using UI Version


import {createVersionLink} from 'stickyants-sp-util'; 

//first major version link 
var delveLink = createVersionLink(512);

3 Using async/await to work with JSOM


import {executeOnContext} from 'stickyants-sp-util'; 


var ctx = new SP.ClientContext();
var web = ctx.get_web(); 
ctx.load(web); 
await executeOnContext(ctx); 
console.log(web.get_title()); 

4 Working with folders

4.1 Creating a nested folder structure in SharePoint list


import {createFolderInListIfNotExist} from 'stickyants-sp-util'; 

var ctx = new SP.ClientContext();
var web = ctx.get_web(); 
var pages = web.get_lists().getByTitle('Pages'); 
var folder = await createFolderInListIfNotExist(ctx,pages,'folder1/folder2/folder3');//returns folder3

4.2 Check if folder exists in List


import {folderExistsInList} from 'stickyants-sp-util'; 

var ctx = new SP.ClientContext();
var web = ctx.get_web(); 
var pages = web.get_lists().getByTitle('Pages'); 
var result = await folderExistsInList(ctx,pages,'folder3'); //returns true/false

5 Publishing Infrastructure

5.1 Creating a publishing page


import {createPublishingPage} from 'stickyants-sp-util'; 

var ctx = new SP.ClientContext();
var result = await createPublishingPage(ctx,'somfile','My Content Type Name'); 

5.2 Getting page layout that is associated with a specific content type


import {getPageLayoutItemByAssociatedContentType} from 'stickyants-sp-util'; 

var ctx = new SP.ClientContext();
var result = await getPageLayoutItemByAssociatedContentType(ctx,'My Content Type Name'); 

6 SharePoint Error Codes (JSOM)


/**
 * JSOM error codes, the possible values of error codes that JSOM 
 * can return 
 */
export enum SPErrorCode {
    /**
     * The accessed item has been deleted
     */
    ItemDoesNotExist = -2147024809,
    /**
     * Some unknown error
     */
    GenericError = -1,
    /**
     * User does not have permission to access/perform operation 
     */
    AccessDenied = -2147024891,
    /**
     * A document with the same name already exist and the user is attempting to add new file/folder
     */
    DocAlreadyExists = -2130575257,
    /**
     * A version that is more recent has been saved 
     */
    VersionConflict = -2130575339,
    /**
     * List item is in recycle bin 
     */
    ListItemDeleted = -2130575338,
    /**
     * A field value that has been provided is invalid
     */
    InvalidFieldValue = -2130575155,
    /**
     * Operation not supported
     */
    NotSupported = -2147024846,
    /**
     * 
     */
    Redirect = -2130575152,
    /**
     * 
     */
    NotSupportedRequestVersion = -2130575151,
    /**
     * A specific field validation has failed 
     */
    FieldValueFailedValidation = -2130575163,
    /**
     * Item update failed validation rules
     */
    ItemValueFailedValidation = -2130575162,
}